Template:Example Stack
| This template uses Lua: |
Calls {{Template example}} for each set of parameters.
Parameters within each set are separated by \, and the sets themselves are separated by |. The template name is taken from the current page title, up to the first slash, but it can be specified explicitly using |t= (or |template=).
Many of the parameters used by {{Template example}} are available, but without the leading underscore: |style=, |sep=, |nobr=, |spaced=, |nocat=, |prefix=, and |postfix=. Within individual examples, you can use \_alias=, \_prefix=, and \_postfix=, as well as \_comment=, \_after=, and \_before= to annotate the example (but take care with equals signs; see below). The character at the start of each line is set using |opener= (the default is : , which creates an indent). Wikitext to insert between examples is supplied using |between= (for example, {{^}}; the default is an empty string, except when |style=*pre is used, in which case the value is {{^|3em}}).
The template also supports substitution.
Examples
[edit]{{Example Stack|t{{=}}Allcaps|apple|banana|carrot}}
- ↓
{{Allcaps|apple}}→ apple{{Allcaps|banana}}→ banana{{Allcaps|carrot}}→ carrot
To make the code easier to read, you can put each set of parameters on a separate line:
{{Example Stack|t=Allcaps
|apple
|banana
|carrot\_comment{{=}}(Converts the text to uppercase.)
}}
- ↓
{{Allcaps|apple}}→ apple{{Allcaps|banana}}→ banana{{Allcaps|carrot}}→ carrot (Converts the text to uppercase.)
Unlike {{Template example}}, {{tc}}, and some other templates, literal equals signs do not work directly, so use {{=}} instead. Also, if your template uses parameter names that begin with an underscore, use _ in its place. If your examples contain many named parameters, it is convenient to use N= at the start of each line to specify the parameter number, for example:
{{Example Stack|t=Yesno|style=wikitable|spaced=1
|1=yes\yes=Accepted\no=Rejected\def=Unknown
|2=no\yes=Accepted\no=Rejected\def=Unknown
|3=maybe\yes=Accepted\no=Rejected\def=Unknown
}}
- ↓
| Code | Result |
|---|---|
{{Yesno |yes |yes=Accepted |no=Rejected |def=Unknown }} |
Accepted |
{{Yesno |no |yes=Accepted |no=Rejected |def=Unknown }} |
Rejected |
{{Yesno |maybe |yes=Accepted |no=Rejected |def=Unknown }} |
Unknown |
By default, leading and trailing spaces and line breaks are trimmed from unnamed parameters (separated by |). To disable this behavior, use |trim=0. However, if you use N= at the beginning of a line, those parameters will still be trimmed, because this behavior is built into the parser.
TemplateData
[edit]TemplateData for Example Stack
| This template needs TemplateData. Please add a TemplateData section, including {{TemplateData header}}, if you are able. |