Difference between revisions of "Template:SetProp/single"

From Salem Wiki
Jump to: navigation, search
m (Protected "Template:SetProp/single": High traffic page ([edit=sysop] (indefinite) [move=sysop] (indefinite)) [cascading])
m (Special handling of 'Locations')
Line 6: Line 6:
 
--><dd>You need to provide both '''prop''' and '''val''' parameters !<!--
 
--><dd>You need to provide both '''prop''' and '''val''' parameters !<!--
 
--></dl>
 
--></dl>
| #default = {{#arraymap:{{{val|}}}|{{{sep|,}}} |xXx |{{#set:{{{prop|}}}=xXx}} |}}
+
| #default = {{
 +
#switch: {{{prop|}}}
 +
| Locations = {{#arraymap:{{{val|}}}|{{{sep|,}}} |xXx |{{#set:{{{prop|}}}=Terrain#xXx}} |}}
 +
| #default = {{#arraymap:{{{val|}}}|{{{sep|,}}} |xXx |{{#set:{{{prop|}}}=xXx}} |}}
 +
}}
 
}}</onlyinclude><noinclude>{{documentation}}</noinclude>
 
}}</onlyinclude><noinclude>{{documentation}}</noinclude>

Revision as of 03:03, 8 July 2012

SetProp/single:
You need to provide both prop and val parameters !


Template documentation (for the template shown above, sometimes hidden or invisible)

Description

This template is used, by {{SetProp}}, to automate calls to {{#set:}}
It uses {{#arraymap:}} as a wrapper to split and inject arguments.

Syntax

Type the below code somewhere in your code: {{SetProp/single|prop=|val=}}
It accepts these named-parameters:
  • prop
    Mandatory; The name of the property to set
  • val
    Mandatory; A sequence of values to assign to the property, one-at-a-time.
  • sep
    Optional; The separator used between the values in the sequence of val.
    Defaults to a comma ','.

Examples

  1. {{SetProp/single|prop=RequiresTech|val=Simple Fences, Quarrying}}
    Would execute:
    {{#arraymap:Simple Fences, Quarrying|, |xXx |{{#set:RequiresTech=xXx}} |}}
    Would execute:
    {{#set:RequiresTech=Simple Fences}}
    {{#set:RequiresTech=Quarrying}}
  2. {{SetProp/single|prop=Locations|val=Grassland, Forests}}
    Would execute:
    {{#arraymap:Grassland, Forests|, |xXx |{{#set:Locations=Terrain/xXx}} |}}
    Would execute:
    {{#set:Locations=Terrain/Grassland}}
    {{#set:Locations=Terrain/Forests}}