|
|
(2 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| {{#if:{{{array|}}}|<!-- | | {{#if:{{{array|}}}|<!-- |
− | -->{{#ifeq: 1|1|<!--
| |
| -->{{#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}} }}<!-- |
| + | |
| + | TODO: get token and pattern args working |
| -->{{#vardefine: token | {{{token|@@@@@}}} }}<!-- | | -->{{#vardefine: token | {{{token|@@@@@}}} }}<!-- |
| -->{{#vardefine: pattern | {{{pattern|{{#var:token}}}}} }}<!-- | | -->{{#vardefine: pattern | {{{pattern|{{#var:token}}}}} }}<!-- |
− | --> token: ({{#var:token}}) pattern: ({{#var:pattern}})<!-- | + | --><!-- token: ({{#var:token}}) pattern: ({{#var:pattern}}) --><!-- |
| + | |
| -->{{{beforefirst|{{{before|}}}}}}<!-- | | -->{{{beforefirst|{{{before|}}}}}}<!-- |
− | -->{{#arrayprint: inarray |{{{after|}}}{{{between|}}}{{{before|}}}|{{#var:token}}|{{#var:pattern}}}}<!-- | + | -->{{#arrayprint: inarray |{{{after|}}}{{{between|}}}{{{before|}}}|@@@@@|@@@@@}}<!-- |
| -->{{{afterlast|{{{after|}}}}}}<!-- | | -->{{{afterlast|{{{after|}}}}}}<!-- |
− | -->|<!--
| |
− | -->{{#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,
| |
− | if this is the last and we have a "beforelast" specified, we use that. Finally, if neither of these
| |
− | is satisfied, we use "before". This means that in a one-item list we will use "beforefirst" and not
| |
− | "beforelast".
| |
− |
| |
− | -->{{#ifexpr: ({{#var: isfirst}}) and ({{#ifeq: {{{beforefirst|--NoValue--}}} | --NoValue-- |0|1}}) <!--
| |
− | -->|<!-- First item and we have a "beforefirst"
| |
− | -->{{{beforefirst}}}<!--
| |
− | -->|<!-- 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}} }}<!--
| |
− | -->}}<!--
| |
− | -->}}<!--
| |
| -->}} | | -->}} |