Difference between revisions of "Template:Map"

From ScummVM :: Wiki
Jump to navigation Jump to search
m (Adjust the index)
(Fill the usage text)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{#explode:{{{values}}}|#|
<includeonly>{{#explode:#{{{values}}}|#|
{{#expr:
{{#expr:
{{#len:{{#if:{{#pos:{{{keys}}}|{{{key}}}}}|{{#sub:#{{{keys}}}|0|{{#pos:#{{{keys}}}|{{{key}}}}}}}|}}}}
{{#len:{{#if:{{#pos:#{{{keys}}}#|#{{{key}}}#}}|{{#sub:#{{{keys}}}|0|{{#pos:##{{{keys}}}#|#{{{key}}}#}}}}|}}}}
-
-
{{#len:{{#if:{{#pos:{{{keys}}}|{{{key}}}}}|{{#replace:{{#sub:#{{{keys}}}|0|{{#pos:#{{{keys}}}|{{{key}}}}}}}|#|}}|}}}}
{{#len:{{#if:{{#pos:#{{{keys}}}#|#{{{key}}}#}}|{{#replace:{{#sub:#{{{keys}}}|0|{{#pos:##{{{keys}}}#|#{{{key}}}#}}}}|#|}}|}}}}
- 1
}}
}}
}}
}}</includeonly><noinclude>
 
This template returns the value mapped to a key, given a list of keys and their associated values.
<!--
=Usage=
{{#sub:#{{{keys}}}|0|{{#expr:{{#if:{{#pos:{{{keys}}}|{{{key}}}}}|{{#pos:{{{keys}}}|{{{key}}}}}|-1}} + 1}} }}·
<nowiki>{{</nowiki>Map|''keys''=<list_of_keys>|''values''=<list_of_values>|''key''=<key><nowiki>}}</nowiki>
{{#if:{{#pos:{{{keys}}}|{{{key}}}}}|{{#pos:{{{keys}}}|{{{key}}}}}|-1}}·
* ''keys'' is a list of keywords separated by the # symbol.
{{#expr:{{#len:{{#sub:#{{{keys}}}|0|{{#pos:#{{{keys}}}|{{{key}}}}}}}}} - {{#len:{{#replace:{{#sub:#{{{keys}}}|0|{{#pos:#{{{keys}}}|{{{key}}}}}}}|#|}}}}}}
* ''values'' is a list of values separated by the # symbol.
-->
* ''key'' is the element that will be used to find its associated value.
The ''keys'' and ''values'' lists must have the same number of elements. In case the given ''key'' isn't found in the ''keys'' list, an empty string is returned.
=Examples=
* <nowiki>{{</nowiki>Map|''keys''=a#b#c|''values''=First value#Second value#Third value|''key''=b<nowiki>}}</nowiki><br>Will make the selection on this map:<br>a = First value<br>b = Second value<br>c = Third value<br>And will show: Second value<br>
</noinclude>

Latest revision as of 09:27, 9 April 2010

This template returns the value mapped to a key, given a list of keys and their associated values.

Usage

{{Map|keys=<list_of_keys>|values=<list_of_values>|key=<key>}}
  • keys is a list of keywords separated by the # symbol.
  • values is a list of values separated by the # symbol.
  • key is the element that will be used to find its associated value.

The keys and values lists must have the same number of elements. In case the given key isn't found in the keys list, an empty string is returned.

Examples

  • {{Map|keys=a#b#c|values=First value#Second value#Third value|key=b}}
    Will make the selection on this map:
    a = First value
    b = Second value
    c = Third value
    And will show: Second value