W3TPL/tag/let
Jump to navigation
Jump to search
About
Action: Assigns a value to a variable.
Options
These are currently in flux, and documentation here may not reflect what actually works.
- "input" = input stage (determining where the input value should come from, and retrieving it); handled by
GetTagInput() - "calc" = doing things with the retrieved input; handled by
UseTagInput() - "output: = putting the results other places besides the target variable; also handled by
UseTagInput()
core
Support for this attribute is required in order for the tag to fulfill its basic purpose.
- name=: name of variable to receive the calculated value
supported
- 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
- echo (output): display the resulting value (at the tag's location in the page)
- This should probably be deprecated. 2022-04-11
- 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
- self (input): use output variable's current value as input for processing
- e.g. for incremental operations
- self (input): takes starting value from same variable, to allow unary operations
- 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 to use as input
unsupported
These are currently not enabled. Code to support some of them exists, though it may not be working.
- index=: treats the target variable (specified by <{{{1}}}>) as an array, and specifies the element to use
- load (should probably be "fetch"): retrieve starting value from the current page's properties
- opposite of "save"
- null: set the calculated value to NULL
- null (input): use NULL as the input
- oparse is now just "parse"
- page= (input): name of wiki page to use as input (instead of tag contents)
- raw: if present, "save" will store the value as an unserialized string
- The default is to serialize it, preserving variable type.
- I think this only applied to <save>.
- save (should probably be "store"): store the result in the properties for the current page
- opposite of "load"
History
- 2011-05-31 (MainProcess()) added "tag" attribute
- 2016-09-22 (MainProcess()) adapting as method of LET tag object
- 2017-10-30 (MainProcess()) major rewrite of everything
- changing from static to dynamic
- using internal properties
- 2017-11-01 rewrite
- Removing support for "load" attribute until we have a usage case.
- It doesn't make sense to load a value you'd have to save anyway.
- (Different page, perhaps? But when would we need that? Need usage case.)
- (MainProcess()) copied code from DoFromScalar() to MainProcess(), which will replace it
- 2018-06-04 This currently saves the property values in RAW format (not serialized).
- To change this, replace SaveValueRaw() with SaveValue().
- 2020-08-17 (MainProcess()) upgrades and fixes
- Somehow, Var::GetValue_fromExpression() wasn't being called to interpret "val=" expressions. I've reinstated it. Not sure if there are other attributes where it should be applied. If they come up, document them.
- 2020-09-24 introducing the 'raw' attribute, which saves in non-serialized format
- Now saving serialized by default.
- 2022-04-08 Belatedly saving the figured value into the variable. Where was that being done before?
- 2022-04-09 MainProcess() is, uh, no longer being called...
- STAGE 1 was replaced by GetTagInput() (input is retrieved from somewhere)
- STAGE 2 now replaced by UseTagInput() (operations are done on the input)