Difference between revisions of "Template:GetMasterCategoryList"
(Marked this version for translation) |
|||
Line 7: | Line 7: | ||
<nowiki>{{GetMasterCategoryList</nowiki><br/> | <nowiki>{{GetMasterCategoryList</nowiki><br/> | ||
|category=Arts, Crafts and Hobbies<br/> | |category=Arts, Crafts and Hobbies<br/> | ||
− | | | + | |master1=Crime<br/> |
|master2=Punishment<br/> | |master2=Punishment<br/> | ||
}}<br/> | }}<br/> | ||
Line 14: | Line 14: | ||
{{GetMasterCategoryList | {{GetMasterCategoryList | ||
|category=Arts, Crafts and Hobbies | |category=Arts, Crafts and Hobbies | ||
− | | | + | |master1=Crime |
|master2=Punishment}} | |master2=Punishment}} | ||
Line 24: | Line 24: | ||
<!--T:6--> | <!--T:6--> | ||
− | It then looks to see if the {{{ | + | It then looks to see if the {{{master1}}} argument specified that the honor is part of some other Master Award, and if it is, it adds that to mlist. If mlist already has something assigned to it, the code will append mlist with a <nowiki><br/></nowiki> tag before appending the master award category. It then repeats that logic using {{{master2}}}. |
<!--T:7--> | <!--T:7--> | ||
After the switch statement we have this:<br/> | After the switch statement we have this:<br/> | ||
− | <nowiki>{{#if:{{{ | + | <nowiki>{{#if:{{{master1|}}}|...</nowiki><br/> |
− | The goal of that statement is so that we can add a <nowiki><br></nowiki> to mlist if the {{{ | + | The goal of that statement is so that we can add a <nowiki><br></nowiki> to mlist if the {{{master1}}} parameter was provided. Then :<br/> |
<nowiki>{{#varexists:mlist|{{#vardefine:mlist|{{#var:mlist}}<br>}}}}</nowiki> | <nowiki>{{#varexists:mlist|{{#vardefine:mlist|{{#var:mlist}}<br>}}}}</nowiki> | ||
Which checks to see if we had assigned anything to mlist in the switch statement previously, and if we did, it redefines mlist (<nowiki>{{#vardefine:mlist...</nowiki>) by repeating the contents of mlist (<nowiki>{{#var:mlist}}</nowiki>) followed by the line break (<nowiki><br></nowiki>). It then repeats similar logic to append the category link to mlist:<br> | Which checks to see if we had assigned anything to mlist in the switch statement previously, and if we did, it redefines mlist (<nowiki>{{#vardefine:mlist...</nowiki>) by repeating the contents of mlist (<nowiki>{{#var:mlist}}</nowiki>) followed by the line break (<nowiki><br></nowiki>). It then repeats similar logic to append the category link to mlist:<br> | ||
− | <nowiki>{{#vardefine:mlist|{{#var:mlist}}[[:Category:AY Honors/{{{ | + | <nowiki>{{#vardefine:mlist|{{#var:mlist}}[[:Category:AY Honors/{{{master1}}} Master Award{{!}}{{{master1}}} Master Award]]}}</nowiki> |
<!--T:8--> | <!--T:8--> | ||
Line 43: | Line 43: | ||
| Household Arts ={{#vardefine:mlist|[[:Category:AY Honors/Homemaking Master Award{{!}}Homemaking Master Award]]}} | | Household Arts ={{#vardefine:mlist|[[:Category:AY Honors/Homemaking Master Award{{!}}Homemaking Master Award]]}} | ||
}} | }} | ||
− | {{#if:{{{ | + | {{#if:{{{master1|}}}|{{#varexists:mlist|{{#vardefine:mlist|{{#var:mlist}}<br>}}}}{{#vardefine:mlist|{{#var:mlist}}[[:Category:AY Honors/{{{master1}}} Master Award{{!}}{{{master1}}} Master Award]]}}}} |
{{#if:{{{master2|}}}|{{#varexists:mlist|{{#vardefine:mlist|{{#var:mlist}}<br>}}}}{{#vardefine:mlist|{{#var:mlist}}[[:Category:AY Honors/{{{master2}}} Master Award{{!}}{{{master2}}} Master Award]]}}}}{{#var:mlist}}</includeonly> | {{#if:{{{master2|}}}|{{#varexists:mlist|{{#vardefine:mlist|{{#var:mlist}}<br>}}}}{{#vardefine:mlist|{{#var:mlist}}[[:Category:AY Honors/{{{master2}}} Master Award{{!}}{{{master2}}} Master Award]]}}}}{{#var:mlist}}</includeonly> | ||
<noinclude></translate></noinclude> | <noinclude></translate></noinclude> |
Revision as of 02:17, 21 January 2021
This template outputs a <br/> separated list of category links to the Master Awards an honor belongs to. It was designed to be used by the honor_infobox template.
Example
{{GetMasterCategoryList
|category=Arts, Crafts and Hobbies
|master1=Crime
|master2=Punishment
}}
Artisan Master Award
Crime Master Award
Punishment Master Award
Mechanics
The output list is stored in a variable called mlist (master list) and that is emitted at the end of the template.
It starts by looking at the {{{category}}} parameter and assigning a mlist to one of the category-based Master Awards. Not every honor category results in a Master Award, so the switch statement doesn't deal with all of the known categories. In other words, mlist may or may not be empty when we come out of the switch statement.
It then looks to see if the {{{master1}}} argument specified that the honor is part of some other Master Award, and if it is, it adds that to mlist. If mlist already has something assigned to it, the code will append mlist with a <br/> tag before appending the master award category. It then repeats that logic using {{{master2}}}.
After the switch statement we have this:
{{#if:{{{master1|}}}|...
The goal of that statement is so that we can add a <br> to mlist if the {{{master1}}} parameter was provided. Then :
{{#varexists:mlist|{{#vardefine:mlist|{{#var:mlist}}<br>}}}}
Which checks to see if we had assigned anything to mlist in the switch statement previously, and if we did, it redefines mlist ({{#vardefine:mlist...) by repeating the contents of mlist ({{#var:mlist}}) followed by the line break (<br>). It then repeats similar logic to append the category link to mlist:
{{#vardefine:mlist|{{#var:mlist}}[[:Category:AY Honors/{{{master1}}} Master Award{{!}}{{{master1}}} Master Award]]}}
Note that the {{!}} template is used to output a | within the [[:Category... link so that we can indicate the text displayed as the link. The use of the {{!}} template is necessary to prevent the {{#vardefine...}} function from interpreting it as its own separator.