W3TPL/tag/get-let

From Woozle Writes Code
< W3TPL‎ | tag
Revision as of 00:10, 21 April 2022 by Woozle (talk | contribs)
Jump to navigation Jump to search

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 and self assumed, except it doesn't store the result.
  • 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).
    • requires a name= attribute.
    • if echo and self are used, is like <get> except it stores the result in a named 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