W3TPL/tag/get-let

From Woozle Writes Code
< W3TPL‎ | tag
Revision as of 00:19, 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 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 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 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

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

History

  • 2022-04-20 moved common attributes from c_let to caTag_Var, so <get> and <let> can share the same processing code.
    • Have not yet updated get to use this, though.