Template:Arrayprint

From Tremor Mod Wiki
Jump to: navigation, search

Approximate recreation of the {{#arrayprint:}} parser function. It takes the following parameters:

{{ arrayprint | <key> | <delimiter> | <subject> }}

  • key is the name of the array to print
  • delimiter is the delimiter between the elements of the array (defaults to , )
  • subject is a formatting style applied to each element; it accepts wiki links, templates, parser functions, etc.
    • Note that due to the limitations and idiosyncrasies of wikitext, this part works very differently than the original parser function does:
      • There is no pattern parameter, the placeholder for the array element is instead always {{#var:array_elem}}.
      • The subject is not defined in the template parameter, but on a separate page: {{arrayprint/subject definitions}}. There, subjects are assigned an identifier, which in turn is what is entered as a parameter value in the template call.
      • Therefore, it is most often necessary to define a new custom subject in {{arrayprint/subject definitions}} and set the subject parameter to the identifier of that new subject.

See {{arraydefine}} for a recreation of the {{#arraydefine:}} parser function.

Examples:

Code Result
{{arraydefine|a|1,2,3,4,5}}
{{arrayprint|a}} 1, 2, 3, 4, 5
{{arrayprint|a|<br/>}} 1
2
3
4
5
* {{arrayprint|a|<nowiki />
* }}
  • 1
  • 2
  • 3
  • 4
  • 5
<ul>
    <li> {{arrayprint|a|</li><li>}} </li>
</ul>
  • 1
  • 2
  • 3
  • 4
  • 5
{{arraydefine|a|Green Slime, Spiked Slime, Shadow Slime}}
{{arrayprint|a|&#32;and&#32;}} Green Slime and Spiked Slime and Shadow Slime
{{arrayprint|a|<br/>|thisdoc1}}

(subject definition: [[Slimes|{{#var:array_elem}}]])

Green Slime
Spiked Slime
Shadow Slime
{{arrayprint|a|<br/>|thisdoc2}}

(subject definition: {{eil|{{#var:array_elem}}}})

Template:Eil
Template:Eil
Template:Eil
{{arrayprint|a|<br/>|thisdoc3}}

(subject definition: [[{{#var:array_elem}}]] {{eicons|{{#var:array_elem}}}})

Green Slime Template:Eicons
Spiked Slime Template:Eicons
Shadow Slime Template:Eicons
{{arrayprint|a|,&#32;|foo bar}}

(no subject definition available for foo bar)

Green Slime, Spiked Slime, Shadow Slime