User:MyNameIsJason
![]() |
Do you need help? If you are in need of assistance with any aspect of Weezerpedia, the best way to get questions answered is to join our Discord server! Here's an invite link: https://discord.gg/GCFFrkqy22. If you really don't want to join, you can reach out to one of Weezerpedia's administrators. Choose who you would like to help you from that list, and leave a message on their talk page with questions. |
Hi! I'm Jason. :)
About me | ||||||||||||||||||||
|
#if template
{{#if:{{{release d|}}}|on|in|}}
I used this example in the album page machine template. It fills in the first sentence of the lede of an album page with one of two options: the word "on," (i.e. "on March 12") or the word "in" (i.e. "in 2023"), depending on whether or not the user inputs a release date (i.e. "March 12") into the infobox. If they only put 2023 as a year and leave the release date blank, the template will "by default" make the lead "in {{{year}}}".
but you don't have to remember that to understand this
Just think this:
{{#if:{{{template parameter|}}}|yes|no|}}
I should replace the "yes" slot with whatever I want to appear if the template parameter is filled in by the user. In this case it actually doesn't matter what they input - they can keysmash as long as it doesn't trip up the syntax. The #if template changes the behavior of a template to not merely call and replace information - in a way it is an simpler task for the wiki to process: "is the parameter empty or not?" If it isn't empty, the template will transclude whatever you have in the "yes" slot to the page.
{{#if:{{{template parameter|}}}|yes|no|}}
I should replace the "no" slot with whatever I want to appear "by default." In the case that the editor doesn't fill this parameter in, or doesn't even list the parameter at all, the template will display whatever you type in the "no" slot. If you're reading this, go back to the release date example above and read it again - I think it will make more sense.