W3TPL/tag/get-let: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
==About== | ==About== | ||
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 | 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 opposite operations. | ||
* '''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. | ||
Line 13: | Line 13: | ||
==Attributes== | ==Attributes== | ||
Each attribute | Each attribute is processed within a given stage, where stages are processed in essentially this order: | ||
* '''input''' | * <code>GetTagInput()</code>: | ||
* '''calc''' | ** '''(input)''' = input stage (determining where the input value should come from, and retrieving it) | ||
** Note that we can't really count on MediaWiki's parser preserving the order of attributes within a tag. | * <code>UseTagInput()</code>: | ||
** '''(calc)''' = doing things with the retrieved input. The output of each operation becomes the input for the next. | |||
*** Note that we can't really count on MediaWiki's parser preserving the order of attributes within a tag, however. | |||
** '''(output)''': = putting the results other places besides the target variable | |||
The following attributes are common to both <code>get</code> and <code>let</code>: | |||
* '''append''' (calc): append the input string to the current value | * '''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 | ||
Line 37: | Line 40: | ||
** opposite of "lcfirst" | ** opposite of "lcfirst" | ||
* '''val=''' (input): value/expression to use as input | * '''val=''' (input): value/expression to use as input | ||
==History== | |||
* '''2022-04-20''' moved common attributes from <code>c_let</code> to <code>caTag_Var</code>, so {{l/w3tpl/tag|get}} and {{l/w3tpl/tag|let}} can share the same processing code. | |||
** Have not yet updated <code>get</code> to use this, though. |
Revision as of 00:19, 21 April 2022
About
The <get> and <let> tags are very similar, and can do similar things, even though in a way they are opposite operations.
- 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 is processed within a given stage, where stages are processed in essentially this order:
GetTagInput()
:- (input) = input stage (determining where the input value should come from, and retrieving it)
UseTagInput()
:- (calc) = doing things with the retrieved input. The output of each operation becomes the input for the next.
- Note that we can't really count on MediaWiki's parser preserving the order of attributes within a tag, however.
- (output): = putting the results other places besides the target variable
- (calc) = doing things with the retrieved input. The output of each operation becomes the input for the next.
The following attributes are common to both get
and let
:
- 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