From GamingWiki
Line 5: | Line 5: | ||
| {{#vardefineecho: theitem | | {{#vardefineecho: theitem | ||
| {{#explode: {{{array}}} | {{#var: sep}} | {{#var: i}} }} | | {{#explode: {{{array}}} | {{#var: sep}} | {{#var: i}} }} | ||
− | |||
− | |||
}}{{#vardefine: nextitem | }}{{#vardefine: nextitem | ||
| {{#explode:{{{array}}}|{{#var: sep}}| {{#expr: {{#var: i}} + 1 }} }} | | {{#explode:{{{array}}}|{{#var: sep}}| {{#expr: {{#var: i}} + 1 }} }} | ||
}} | }} | ||
|<!-- | |<!-- | ||
− | -->{{# | + | -->{{#vardefine: isfirst |<!-- |
− | -->| {{#var: | + | -->{{#ifeq: {{#var: i}} | {{{countfrom|1}}} | 1 | }} }}<!-- Is this the first item in the list |
− | -->| {{#var: | + | -->{{#vardefine: islast |<!-- |
− | + | -->{{#if: {{#var: nextitem}} | | 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". | ||
+ | |||
+ | -->{{#if: ({{#var: isfirst}}) and ({{#ifeq: {{{beforefirst|--NoValue--}}} | --NoValue-- ||1}}) <!-- | ||
+ | -->|<!-- First item and we have a "beforefirst" | ||
+ | -->{{{beforefirst}}}<!-- | ||
+ | -->|<!-- not the first item, or no "beforefirst" | ||
+ | -->{{#if: ({{#var: islast}}) and ({{#ifeq: {{{beforelast|--NoValue--}}} | --NoValue-- ||1}}) <!-- | ||
+ | -->|<!-- Last item and we have a "beforelast" | ||
+ | -->{{{beforelast}}}<!-- | ||
+ | -->|<!-- fall through to the default | ||
+ | -->{{{before|}}}<!-- | ||
+ | -->}}<!-- | ||
-->}}<!-- | -->}}<!-- | ||
-->{{#var: theitem}}<!-- | -->{{#var: theitem}}<!-- | ||
− | -->{{# | + | |
− | + | For the "after" we give precedence to "afterlast" over "afterfirst". | |
− | -->| {{#var: | + | |
− | + | -->{{#if: ({{#var: islast}}) and ({{#ifeq: {{{afterlast|--NoValue--}}} | --NoValue-- ||1}}) <!-- | |
+ | -->|<!-- last item and we have a "afterlast" | ||
+ | -->{{{afterlast}}}<!-- | ||
+ | -->|<!-- not the last item, or no "afterlast" | ||
+ | -->{{#if: ({{#var: isfirst}}) and ({{#ifeq: {{{afterfirst|--NoValue--}}} | --NoValue-- ||1}}) <!-- | ||
+ | -->|<!-- first item and we have a "afterfirst" | ||
+ | -->{{{afterfirst}}}<!-- | ||
+ | -->|<!-- fall through to the default | ||
+ | -->{{{after|}}}<!-- | ||
+ | -->}}<!-- | ||
-->}}<!-- | -->}}<!-- | ||
+ | |||
-->{{#vardefine: i | {{#expr: {{#var: i}} + 1}} }}<!-- | -->{{#vardefine: i | {{#expr: {{#var: i}} + 1}} }}<!-- | ||
-->}}<!-- | -->}}<!-- | ||
-->}} | -->}} |