Dplvar: Difference between revisions
imported>FrozenPlum m (Make this a bit easier to understand) |
imported>FrozenPlum m (Formatting fixes/changes) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
==Syntax== |
==Syntax== |
||
'''Sets one''' symbolic variable name and assign a value: |
* '''Sets one''' symbolic variable name and assign a value: |
||
⚫ | |||
<pre> |
|||
⚫ | |||
</pre> |
|||
'''Sets multiple''' symbolic variable names '''and assigns''' values to them (one after the other): |
* '''Sets multiple''' symbolic variable names '''and assigns''' values to them (one after the other): |
||
<pre> |
<pre> |
||
{{#dplvar:set|name1|value1|name2|value2|..|..}} |
{{#dplvar:set|name1|value1|name2|value2|..|..}} |
||
</pre> |
</pre> |
||
'''Assigns''' a value '''only if the variable is empty / has not been used''' so far: |
* '''Assigns''' a value '''only if the variable is empty / has not been used''' so far: |
||
<pre> |
<pre> |
||
{{#dplvar:default|name|value}} |
{{#dplvar:default|name|value}} |
||
</pre> |
</pre> |
||
'''Returns''' the current value of the variable: |
* '''Returns''' the current value of the variable: |
||
<pre> |
<pre> |
||
{{#dplvar:name}} |
{{#dplvar:name}} |
||
</pre> |
</pre> |
||
{{note| |
{{note|'''Note:''' Variables can be set and retrieved from an article, or from templates used in that article.}} |
||
⚫ | |||
<pre> |
|||
{{#dplvar:set|a|x|b|y|c|<!--empty-->}} {{#dplvar:default|a|aaaa}} {{#dplvar:default|c|cccc}} {{#dplvar:default|d|dddd}} |
|||
</pre> |
|||
{{#dplvar:set|a|x|b|y|c|<!--empty-->}} {{#dplvar:default|a|aaaa}} {{#dplvar:default|c|cccc}} {{#dplvar:default|d|dddd}} |
|||
⚫ | |||
⚫ | |||
'''Part 1:''' |
|||
* a={{#dplvar:a}} |
|||
{{#lsth:Examples/Module: dplvar (example 1)|Part 1}} |
|||
* b={{#dplvar:b}} |
|||
'''Part 1 Result:''' |
|||
* c={{#dplvar:c}} |
|||
{{#lsth:Examples/Module: dplvar (example 1)|Part 1 Result}} |
|||
* d={{#dplvar:d}} |
|||
<br> |
|||
'''Part 2:''' |
|||
{{#lsth:Examples/Module: dplvar (example 1)|Part 2}} |
|||
{{ViewTest|Examples|Module: dplvar (example_1)}} |
|||
'''Part 2 Result:''' |
|||
{{#lsth:Examples/Module: dplvar (example 1)|Part 2 Result}} |
|||
==Example 2== |
|||
⚫ | |||
'''Example:''' |
|||
* Variable "c" was set to "cccc" because it was set but with an empty note (empty value). |
|||
{{#lsth:Examples/Module: dplvar (example_2)|Example}} |
|||
* Variable "d" was set to "dddd" because it was not already set. |
|||
{{ViewTest|Examples|Module: dplvar (example 2)}} |
|||
⚫ | |||
-->{{#lsth:Examples/Module: dplvar (example 2)|Result}} |
|||
[[Category:Other Modules]] |
[[Category:Other Modules]] |
Latest revision as of 03:04, 21 April 2023
|
Manual | dplvar |
Syntax
- Sets one symbolic variable name and assign a value:
{{#dplvar:set|varname|valueofvar}}
- Sets multiple symbolic variable names and assigns values to them (one after the other):
{{#dplvar:set|name1|value1|name2|value2|..|..}}
- Assigns a value only if the variable is empty / has not been used so far:
{{#dplvar:default|name|value}}
- Returns the current value of the variable:
{{#dplvar:name}}
Example 1
Part 1:
{{#lsth:Examples/Module: dplvar (example 1)|Part 1}}
Part 1 Result:
{{#lsth:Examples/Module: dplvar (example 1)|Part 1 Result}}
Part 2:
{{#lsth:Examples/Module: dplvar (example 1)|Part 2}}
Page Template:ViewTest/style.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").
Part 2 Result: {{#lsth:Examples/Module: dplvar (example 1)|Part 2 Result}}
Example 2
Example: {{#lsth:Examples/Module: dplvar (example_2)|Example}}
Page Template:ViewTest/style.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").
Result:{{#lsth:Examples/Module: dplvar (example 2)|Result}}