Jump to content

Template:Foreach: Difference between revisions

linking to Foreach2
(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)
(linking to Foreach2)
 
Line 60: Line 60:
'''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.
'''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]].
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]]. A duplicate of this template exists under the name [[Template:Foreach2|Foreach2]], which should be updated with any changes to this template.


[[Category:Utility templates]]
[[Category:Utility templates]]
</noinclude>
</noinclude>