Difference between revisions of "Template:Save"
Jump to navigation
Jump to search
Kevin Wang (talk | contribs) (Created page with "{{#vardefine:save_i|1}}{{#while:|{{{{{#var:save_i}}|}}}|{{#vardefine:prev_{{{ {{#var:save_i}} }}}|{{#var:{{{ {{#var:save_i}} }}}}}}}{{#vardefine:save_i|{{#expr:{{#var:save_i}}...") |
Kevin Wang (talk | contribs) m |
||
Line 16: | Line 16: | ||
{{Save|x|y|z}} | {{Save|x|y|z}} | ||
{{#vardefine:x|1a}}{{#vardefine:y|2a}}{{#vardefine:z|red}} | {{#vardefine:x|1a}}{{#vardefine:y|2a}}{{#vardefine:z|red}} | ||
− | {{#var: | + | {{#var:x}}, {{#var:y}}, {{#var:z}} |
+ | {{Load|x|y|z}} | ||
+ | {{#var:x}}, {{#var:y}}, {{#var:z}} | ||
</pre> | </pre> | ||
| | | | ||
Line 22: | Line 24: | ||
{{Save|x|y|z}} | {{Save|x|y|z}} | ||
{{#vardefine:x|1a}}{{#vardefine:y|2a}}{{#vardefine:z|red}} | {{#vardefine:x|1a}}{{#vardefine:y|2a}}{{#vardefine:z|red}} | ||
− | {{#var: | + | {{#var:x}}, {{#var:y}}, {{#var:z}} |
+ | {{Load|x|y|z}} | ||
+ | {{#var:x}}, {{#var:y}}, {{#var:z}} | ||
|} | |} | ||
</noinclude> | </noinclude> |
Latest revision as of 11:49, 28 July 2022
Given a list of variable names {x1, x2, x3, ...}, preserve the value of those variables in a new set of variables {prev_x1, prev_x2, prev_x3}.
Use this template to prevent a template from affecting the variables of a page it is transcluded in.
Who knows what will happen if you nest this.
Pair with Template:Load.
Example:
Input | Output |
---|---|
{{#vardefine:x|1}}{{#vardefine:y|2}}{{#vardefine:z|blue}} {{Save|x|y|z}} {{#vardefine:x|1a}}{{#vardefine:y|2a}}{{#vardefine:z|red}} {{#var:x}}, {{#var:y}}, {{#var:z}} {{Load|x|y|z}} {{#var:x}}, {{#var:y}}, {{#var:z}} |
1a, 2a, red
|