Difference between revisions of "Template:PropVals/Group"

From Salem Wiki
Jump to: navigation, search
m (Adding a visual error msg when #args exceed whats supported.)
m (using sub-template for nextparts, to avoid errors in expanding #args. Also removing chained-if's for readability and error prevention.)
Line 3: Line 3:
 
-->{{#sub:{{{1}}} | 0 | {{#rpos:{{{1}}}|{{{sep|;}}} }} }}<!--
 
-->{{#sub:{{{1}}} | 0 | {{#rpos:{{{1}}}|{{{sep|;}}} }} }}<!--
 
-->{{#if: {{{2|}}}
 
-->{{#if: {{{2|}}}
| {{#ifeq: {{PropVals/Split|val={{{1|}}}|part=tail}}
+
| {{PropVals/Group/NextPart
| {{PropVals/Split|val={{{2|}}}|part=tail}}
+
|preval={{{1|}}}
|| {{{grpsep|/\}}} {{PropVals/Split|val={{{2}}}|part=tail}}
+
|val={{{2|}}}
}}<!--
+
|sep={{{sep|;}}}
-->{{!}}{{#sub:{{{2}}} | 0 | {{#rpos:{{{2}}}|{{{sep|;}}} }} }}<!--
+
|grpsep={{{grpsep|/\}}}
 +
}}<!--
 +
-->}}<!--
 
-->{{#if: {{{3|}}}
 
-->{{#if: {{{3|}}}
| {{#ifeq: {{PropVals/Split|val={{{2|}}}|part=tail}}
+
| {{PropVals/Group/NextPart
| {{PropVals/Split|val={{{3|}}}|part=tail}}
+
|preval={{{2|}}}
|| {{{grpsep|/\}}} {{PropVals/Split|val={{{3}}}|part=tail}}
+
|val={{{3|}}}
}}<!--
+
|sep={{{sep|;}}}
-->{{!}}{{#sub:{{{3}}} | 0 | {{#rpos:{{{3}}}|{{{sep|;}}} }} }}
+
|grpsep={{{grpsep|/\}}}
}}<!--
+
}}<!--
 +
-->}}<!--
 
-->{{#if: {{{4|}}}
 
-->{{#if: {{{4|}}}
| {{#ifeq: {{PropVals/Split|val={{{3|}}}|part=tail}}
+
| {{PropVals/Group/NextPart
| {{PropVals/Split|val={{{4|}}}|part=tail}}
+
|preval={{{3|}}}
|| {{{grpsep|/\}}} {{PropVals/Split|val={{{4}}}|part=tail}}
+
|val={{{4|}}}
}}<!--
+
|sep={{{sep|;}}}
-->{{!}}{{#sub:{{{4}}} | 0 | {{#rpos:{{{4}}}|{{{sep|;}}} }} }}
+
|grpsep={{{grpsep|/\}}}
}}<!--
+
}}<!--
-->{{#if: {{{5|}}} | <span class="error">You need to expand the #args of this template to process this many arguments !</span> }}<!--
+
-->}}<!--
 +
-->{{#if: {{{5|}}}
 +
| <span class="error">You need to expand the #args of this template to process this many arguments !</span><!--
 
-->}}
 
-->}}
 
}}
 
}}
 
</onlyinclude><noinclude>{{documentation}}</noinclude>
 
</onlyinclude><noinclude>{{documentation}}</noinclude>

Revision as of 14:44, 22 June 2012

{{{1}}}|{{{1}}


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

Description

  • This is a wrapper-template that generates output, which will be used as arguments for {{PropVals/List}}.
    {{#arraymap:}} will be used as a wrapper, that uses this generated-output, to inject the extra arguments for {{PropVals/List}}.
    This generated-output is a concatenation of grouped-records, using {{PropVals/Group/NextPart}} to output these grouped-records.
  • This wrapper-template is used to feed individual records to its helper-template, {{PropVals/Group/NextPart}}, therefore it has a hard-coded limit on the amount of records it can process !
    This limit, currently 20, can be increased by properly expanding the code inside...

Syntax

Type the below code somewhere inside your code:
{{PropVals/Group |sep={{{sep|;}}} |grpsep={{{grpsep|/\}}} |<record>|<record>|<record>|etc...}}

Examples

  1. {{PropVals/Group|sep={{{sep|;}}}|grpsep={{{grpsep|/\}}}|Lime;15;Startpost |Flint;15;Startpost |Stone;30;Startpost |Lime;8;Cornerpost |Flint;8;Cornerpost |Stone;15;Cornerpost |Flint;1;Wallsegment |Stone;3;Wallsegment |Board;10;Gate |Nails;4;Gate}}
    gives:
    Startpost|Lime;15|Flint;15|Stone;30/\heading=Cornerpost|Lime;8You need to expand the #args of this template to process this many arguments !