From GamingWiki
Jump to: navigation, search
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{#if:{{{array|}}}|<!--
 
{{#if:{{{array|}}}|<!--
-->{{#arraydefine: inarray | {{{array}}} | {{{separator|;;}}} }}<!--
+
  -->{{#arraydefine: inarray | {{{array}}} | {{{separator|;;}}} }}<!--
-->{{#vardefine: countfrom | {{{countfrom|1}}}  }}<!--
+
  -->{{#vardefine: countfrom | {{{countfrom|1}}}  }}<!--
-->{{#arrayslice: thearray | inarray | {{#var: countfrom}} }}<!--
+
  -->{{#arrayslice: thearray | inarray | {{#var: countfrom}} }}<!--
-->{{#vardefine: token | {{{token|}}} | @@@@@ }}<!--
 
-->{{#vardefine: pattern | {{{pattern|}}} | {{#var:token}} }}<!--
 
-->{{{beforefirst|}}}<!--
 
-->{{#arrayprint: inarray |{{{after|}}}{{{between|}}}{{{before|}}}|{{#var:token}}|{{#var:pattern}}}}<!--
 
-->{{{afterlast|}}}<!--
 
-->}}<!--
 
-->{{#ifeq: 0|1|<!--
 
-->{{#vardefine: i  | {{{countfrom|1}}}  }}<!--
 
-->{{#vardefine: sep | {{{separator|;;}}} }}<!--
 
  -->{{#while:
 
    | {{#vardefineecho: theitem
 
      | {{#explode: {{{array}}} | {{#var: sep}} | {{#var: i}} }}
 
      }}{{#vardefine: nextitem
 
      | {{#explode:{{{array}}}|{{#var: sep}}| {{#expr: {{#var: i}} + 1 }} }}
 
      }}
 
    |<!--
 
    -->{{#vardefine: isfirst |<!--
 
      -->{{#ifeq: {{#var: i}} | {{{countfrom|1}}} | 1 | 0 }} }}<!-- Is this the first item in the list
 
    -->{{#vardefine: islast  |<!--
 
      -->{{#if: {{#var: nextitem}}                | 0 | 1 }} }}<!-- Is this the last item in the list
 
  
    If this is the first one in the list, and we have "beforefirst" specified, then we use it. Otherwise,
+
TODO: get token and pattern args working
    if this is the last and we have a "beforelast" specified, we use that. Finally, if neither of these
+
  -->{{#vardefine: token | {{{token|@@@@@}}} }}<!--
    is satisfied, we use "before". This means that in a one-item list we will use "beforefirst" and not
+
  -->{{#vardefine: pattern | {{{pattern|{{#var:token}}}}} }}<!--
    "beforelast".
+
  --><!-- token: ({{#var:token}}) pattern: ({{#var:pattern}}) --><!--
  
    -->{{#ifexpr: ({{#var: isfirst}}) and ({{#ifeq: {{{beforefirst|--NoValue--}}} | --NoValue-- |0|1}}) <!--
+
  -->{{{beforefirst|{{{before|}}}}}}<!--
    -->|<!--    First item and we have a "beforefirst"
+
   -->{{#arrayprint: inarray |{{{after|}}}{{{between|}}}{{{before|}}}|@@@@@|@@@@@}}<!--
      -->{{{beforefirst}}}<!--
+
   -->{{{afterlast|{{{after|}}}}}}<!--
    -->|<!--    not the first item, or no "beforefirst"
 
      -->{{#ifexpr: ({{#var: islast}}) and ({{#ifeq: {{{beforelast|--NoValue--}}} | --NoValue-- |0|1}}) <!--
 
      -->|<!--   Last item and we have a "beforelast"
 
        -->{{{beforelast}}}<!--
 
      -->|<!--  fall through to the default
 
        -->{{{before|}}}<!--
 
      -->}}<!--
 
    -->}}<!--
 
 
 
    -->{{#var: theitem}}<!--
 
 
 
    For the "after" we give precedence to "afterlast" over "afterfirst".
 
 
 
    -->{{#ifexpr: ({{#var: islast}}) and ({{#ifeq: {{{afterlast|--NoValue--}}} | --NoValue-- |0|1}}) <!--
 
    -->|<!--    last item and we have a "afterlast"
 
      -->{{{afterlast}}}<!--
 
    -->|<!--    not the last item, or no "afterlast"
 
      -->{{#ifexpr: ({{#var: isfirst}}) and ({{#ifeq: {{{afterfirst|--NoValue--}}} | --NoValue-- |0|1}}) <!--
 
      -->|<!--   first item and we have a "afterfirst"
 
        -->{{{afterfirst}}}<!--
 
      -->|<!--  fall through to the default
 
        -->{{{after|}}}<!--
 
      -->}}<!--
 
    -->}}<!--
 
 
 
    -->{{#vardefine: i | {{#expr: {{#var: i}} + 1}} }}<!--
 
  -->}}<!--
 
 
-->}}
 
-->}}

Latest revision as of 20:55, 17 February 2011