Template:Foreach

From OniGalore
Revision as of 04:09, 13 December 2015 by Iritscen (talk | contribs) (rewrote docs for rewritten Foreach template; /cat)
Jump to navigation Jump to search

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 specify how many items from the list to send to the template, as there is no easy way to count the items automatically.

Foreach also accepts two pass-through arguments, that is, two arguments to send through to the "call" template in addition to each item from the list being passed to that template as "{{{1}}}"; these arguments are named with "pass_thru_name1" and "pass_thru_name2" and their values are given with "pass_thru_arg1" and "pass_thru_arg2".

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 two named parameters, this template can generate calls to a template like: {{Template|A|format=table|color=blue}}, {{Template|B|format=table|color=blue}}, 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 it is used as part of the BSL documentation, and is explained on BSL:Grouping.