Dungeons and Dragons Wiki:Programming Templates

From Dungeons and Dragons Wiki
Revision as of 03:42, 22 November 2010 by Havvy (talk | contribs) (Created page with "If you don't know how a template works, this is the wrong page to be at. == Required Variables == <pre><nowiki>{{{varname}}}</nowiki></pre> == Optional Variables == <pre><now...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

If you don't know how a template works, this is the wrong page to be at.

Required Variables

{{{varname}}}

Optional Variables

{{#if: {{{varname|}}}|{{{varname}}}|Default display}}

Switches

If you have a list of options allowed.

{{#switch: {{{varname}}}
|value = What to show if |varname = value
|value2 = What to show if |varname = value2
|default value (if you want to show the value of the var, have this just be {{{varname}}}
}}

ArrayMap

{{#arraymap: {{{varName}}}|separating token|stringName|Display for each string}}
Example:
{{#arraymap: {{{desc}}}|, |x|[[Descriptor::x]]}}

In the example, an array map is created for the variable "desc" with each string in the array separated by ", " in the template usage page. The variable to reference each string is called "x" in this array. For each string, it gives it the Descriptor SMW property.

The separating token cannot be modified or hidden. It is probably best to use ", " as the separating token.

Useful Escaping

[ and ] display as [ and ] , respectively, but won't get parsed as wiki links.