W3TPL/tag/get-let: Difference between revisions
Jump to navigation
Jump to search
(Created page with "==About== The {{l/w3tpl/tag|get}} and {{l/w3tpl/tag|let}} tags are very similar, even though conceptually they perform opposite tasks. * '''get''': ** retrieves an input ''or...") |
No edit summary |
||
Line 1: | Line 1: | ||
==About== | ==About== | ||
The {{l/w3tpl/tag|get}} and {{l/w3tpl/tag|let}} tags are very similar, even though | The {{l/w3tpl/tag|get}} and {{l/w3tpl/tag|let}} tags are very similar, and can do similar things, even though in a way they are opposites. | ||
* '''get''': | * '''get''': | ||
** retrieves an input ''or stored'' value and (ultimately) ''outputs it'' to the display. | ** retrieves an input ''or stored'' value and (ultimately) ''outputs it'' to the display. | ||
** is | *** The result is always displayed (though this can be captured and/or hidden by enclosure within another tag). | ||
** does ''not'' require a <code>name=</code> attribute. | ** does ''not'' require a <code>name=</code> attribute. | ||
** is like {{l/w3tpl/tag|let}} with <code>echo</code> and <code>self</code> assumed, except it doesn't store the result. | |||
* '''let''': | * '''let''': | ||
** receives an input value and (ultimately) ''stores it'' as a variable. | ** receives an input value and (ultimately) ''stores it'' as a variable. | ||
*** The result is always stored in a variable (though it can also be displayed with <code>echo</code>). | |||
** requires a <code>name=</code> attribute. | ** requires a <code>name=</code> attribute. | ||
== | ** if <code>echo</code> and <code>self</code> are used, is like {{l/w3tpl/tag|get}} except it stores the result in a named variable. | ||
Both tags have these options in common: | |||
==Attributes== | |||
Each attribute belongs to a given stage, where stages are processed in this order: | |||
* '''input''': the primary input source for further calculations/actions is designated | |||
* '''calc''': zero or more operations are performed on the input, with the output of each one becoming the input for the next | |||
** Note that we can't really count on MediaWiki's parser preserving the order of attributes within a tag. | |||
Both tags have these options in common. | |||
* '''append''' (calc): append the input string to the current value | |||
* '''arg=''' (input): name of POST field to retrieve as tag input | * '''arg=''' (input): name of POST field to retrieve as tag input | ||
** USAGE: form processing | ** USAGE: form processing | ||
* '''chr=''' (input): ASCII number of character to use as tag input | * '''chr=''' (input): ASCII number of character to use as tag input | ||
* '''copy=''' (input): name of another variable whose value should become the input | * '''copy=''' (input): name of another variable whose value should become the input | ||
* '''val=''' (input): value to use as input | * '''lcase''' (calc): apply <code>strtolower()</code>, i.e. convert the input to lower case | ||
** opposite of "ucase" | |||
* '''lcfirst''' (calc): apply <code>lcfirst()</code>, i.e. convert the first character of the input to lower case | |||
** opposite of "ucfirst" | |||
* '''len=''' (calc): use only the first {{arg|len}} characters of the input (this could probably stand some rethinking) | |||
* '''parse''' (calc): have MediaWiki parse the input, and use the resulting string | |||
* '''pre''' (calc): alias for "parse", for backwards compatibility | |||
* '''trim''' (calc): apply <code>trim()</code> | |||
* '''ucase''' (calc): apply <code>strtoupper()</code>, i.e. convert the input to upper case | |||
** opposite of "lcase" | |||
* '''ucfirst''' (calc): apply <code>ucfirst()</code>, i.e. convert the first character of the input to upper case | |||
** opposite of "lcfirst" | |||
* '''val=''' (input): value/expression to use as input |
Revision as of 00:10, 21 April 2022
About
The <get> and <let> tags are very similar, and can do similar things, even though in a way they are opposites.
- get:
- retrieves an input or stored value and (ultimately) outputs it to the display.
- The result is always displayed (though this can be captured and/or hidden by enclosure within another tag).
- does not require a
name=
attribute. - is like <let> with
echo
andself
assumed, except it doesn't store the result.
- retrieves an input or stored value and (ultimately) outputs it to the display.
- let:
- receives an input value and (ultimately) stores it as a variable.
- The result is always stored in a variable (though it can also be displayed with
echo
).
- The result is always stored in a variable (though it can also be displayed with
- requires a
name=
attribute. - if
echo
andself
are used, is like <get> except it stores the result in a named variable.
- receives an input value and (ultimately) stores it as a variable.
Attributes
Each attribute belongs to a given stage, where stages are processed in this order:
- input: the primary input source for further calculations/actions is designated
- calc: zero or more operations are performed on the input, with the output of each one becoming the input for the next
- Note that we can't really count on MediaWiki's parser preserving the order of attributes within a tag.
Both tags have these options in common.
- append (calc): append the input string to the current value
- arg= (input): name of POST field to retrieve as tag input
- USAGE: form processing
- chr= (input): ASCII number of character to use as tag input
- copy= (input): name of another variable whose value should become the input
- lcase (calc): apply
strtolower()
, i.e. convert the input to lower case- opposite of "ucase"
- lcfirst (calc): apply
lcfirst()
, i.e. convert the first character of the input to lower case- opposite of "ucfirst"
- len= (calc): use only the first <len> characters of the input (this could probably stand some rethinking)
- parse (calc): have MediaWiki parse the input, and use the resulting string
- pre (calc): alias for "parse", for backwards compatibility
- trim (calc): apply
trim()
- ucase (calc): apply
strtoupper()
, i.e. convert the input to upper case- opposite of "lcase"
- ucfirst (calc): apply
ucfirst()
, i.e. convert the first character of the input to upper case- opposite of "lcfirst"
- val= (input): value/expression to use as input