Template:++: Difference between revisions
Jump to navigation
Jump to search
Want an adless experience? Log in or Create an account.
(Created page with "<onlyinclude>{{#vardefineecho:{{{1}}}|{{#expr:{{#var:{{{1}}}}}+1}}}}</onlyinclude> ==Purpose== This template slightly simplifies the common task of incrementing a variable. I...") |
(added flexibility with the return value) |
||
Line 1: | Line 1: | ||
<onlyinclude>{{# | <onlyinclude>{{#ifeq:{{{2|}}}|pre|{{#var:{{{1}}}}}}}{{#vardefine:{{{1}}}|{{#expr:{{#var:{{{1}}}}}+1}}}}{{#if:{{{2|}}}||{{#var:{{{1}}}}}}}</onlyinclude> | ||
==Purpose== | ==Purpose== | ||
This template slightly simplifies the common task of incrementing a variable. | This template slightly simplifies the common task of incrementing a variable. By default, it also returns the variable ''post-increment''. An undefined variable is incremented to 1. | ||
==Usage== | ==Usage== | ||
{{Usage|name}} | {{Usage|name}} | ||
{{Usage/Param|name|The name of the variable (without #var syntax).}} | {{Usage/Param|name|The name of the variable (without #var syntax).}} | ||
To return the variable ''pre-increment'', use: {{Usage|name|pre}} | |||
To not return the variable, use: {{Usage|name|no}} | |||
{{Cat|Utility Templates}} | {{Cat|Utility Templates}} |
Revision as of 15:16, June 9, 2013
1
Purpose
This template slightly simplifies the common task of incrementing a variable. By default, it also returns the variable post-increment. An undefined variable is incremented to 1.
Usage
{{++| name }}
- name — The name of the variable (without #var syntax).
To return the variable pre-increment, use: {{++| name | pre }}
To not return the variable, use: {{++| name | no }}