18,700
edits
(rewrote docs for rewritten Foreach template; /cat) |
(extended Foreach from 13 max iterations to 55; removed pass-through arg 2, as we are not using it any longer; updated and improved docs) |
||
Line 1: | Line 1: | ||
<includeonly><!-- | <includeonly><!-- | ||
-->{{#ifexpr:{{{up_to}}}>0|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|1}}|{{{pass_thru_name1}}}={{{pass_thru_arg1 | -->{{#ifexpr:{{{up_to}}}>0|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|1}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>1|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|2}}|{{{pass_thru_name1}}}={{{pass_thru_arg1 | -->{{#ifexpr:{{{up_to}}}>1|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|2}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>2|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|3}}|{{{pass_thru_name1}}}={{{pass_thru_arg1| | -->{{#ifexpr:{{{up_to}}}>2|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|3}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>3|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|4}}|{{{pass_thru_name1}}}={{{pass_thru_arg1 | -->{{#ifexpr:{{{up_to}}}>3|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|4}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>4|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|5}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}} | -->{{#ifexpr:{{{up_to}}}>4|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|5}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>5|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|6}}|{{{pass_thru_name1}}}={{{pass_thru_arg1 | -->{{#ifexpr:{{{up_to}}}>5|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|6}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>6|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|7}}|{{{pass_thru_name1}}}={{{pass_thru_arg1 | -->{{#ifexpr:{{{up_to}}}>6|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|7}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>7|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|8}}|{{{pass_thru_name1}}}={{{pass_thru_arg1 | -->{{#ifexpr:{{{up_to}}}>7|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|8}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>8|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|9}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}} | -->{{#ifexpr:{{{up_to}}}>8|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|9}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>9|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|10}}|{{{pass_thru_name1}}}={{{pass_thru_arg1 | -->{{#ifexpr:{{{up_to}}}>9|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|10}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>10|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|11}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}} | -->{{#ifexpr:{{{up_to}}}>10|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|11}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>11|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|12}}|{{{pass_thru_name1}}}={{{pass_thru_arg1 | -->{{#ifexpr:{{{up_to}}}>11|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|12}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>12|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|13}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}} | -->{{#ifexpr:{{{up_to}}}>12|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|13}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | ||
-->{{#ifexpr:{{{up_to}}}>13|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|14}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>14|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|15}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>15|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|16}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>16|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|17}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>17|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|18}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>18|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|19}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>19|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|20}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>20|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|21}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>21|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|22}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>22|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|23}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>23|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|24}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>24|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|25}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>25|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|26}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>26|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|27}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>27|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|28}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>28|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|29}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>29|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|30}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>30|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|31}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>31|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|32}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>32|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|33}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>33|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|34}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>34|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|35}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>35|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|36}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>36|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|37}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>37|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|38}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>38|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|39}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>39|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|40}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>40|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|41}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>41|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|42}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>42|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|43}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>43|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|44}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>44|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|45}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>45|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|46}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>46|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|47}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>47|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|48}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>48|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|49}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>49|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|50}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>50|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|51}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>51|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|52}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>52|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|53}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>53|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|54}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
-->{{#ifexpr:{{{up_to}}}>54|{{{{{call}}}|{{#explode:{{{item_in}}}|{{{delim|,}}}|55}}|{{{pass_thru_name1}}}={{{pass_thru_arg1|}}}}}}}<!-- | |||
--></includeonly><noinclude> | |||
Heavily adapted from a Wikipedia template of the same name, '''Foreach''' parses the text given by parameter "item_in", turning it into a list of items separated by a delimiter (by default the comma, or specified by the "delim" parameter), then passes each item to a template named in the "call" parameter. You must use the "up_to" parameter to specify how many items from the incoming list to send to the template (maximum of 55), as there is no easy way to count the items automatically. | |||
'''Foreach''' also accepts | '''Foreach''' also accepts a named, fixed pass-through argument, that is, a constant argument to send through to the "call"ed template in addition to each item from the list being passed to that template as "<nowiki>{{{1}}}</nowiki>"; you need to supply the name with "pass_thru_name1" and then give the value with "pass_thru_arg1". In other words, given some text that contains a list like "A,B,C,D", and the name of a template that can process those items as well as taking a named parameter, this template can generate calls to that template like: <nowiki>{{Template|A|use_format=simple}}</nowiki>, <nowiki>{{Template|B|use_format=simple}}</nowiki>, etc. | ||
One quirk of this template is that the first item in the list is ignored; the complex reason for this is due to the way this template was designed to be used as part of the BSL documentation system, and is explained on [[BSL:Grouping]]. | |||
[[Category:Utility templates]] | [[Category:Utility templates]] | ||
</noinclude> | </noinclude> |