You are viewing the MafiaScum.net Wiki. To play the game, visit the forum.

Template:ForEach/doc

From MafiaWiki
Jump to navigation Jump to search
Name:
  • ForEach
Types:
Sub-Template:
  • Yes
Designer:

{{ForEach}} runs a given template on all the elements of a slash-separated string, leaving spaces in between the individual results. Any leading and trailing whitespace on the output is stripped. If the input starts with a letter, it will be capitalised.

The template takes three arguments: the slash-separated string, the template to run on it, and an optional additional argument to that template.

Unfortunately, as shown by the first example below, this template can cause extra calls to the template given as argument, giving it the null string as input. Therefore, you must choose a template that detects this case and produces no output when it happens, as shown in the second example below.

Examples

  • [{{ForEach|1/2/3|tl}}] → [{{1}} {{2}} {{3}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}} {{[[Template:|]]}}]
  • [{{ForEach|abc def/Friendly Neighbour|CL|purple}}] → [Abc def Friendly Neighbour]