Global Lua Modules/T

T is a feature-packed example generator for brace-based wikitext. It allows users to link to and describe templates and module invocations using familiar syntax.

The basics
At its most basic, this template creates fancy links to other templates. For example, here's how you would link to Template:Sandbox:

(We'll be using Template:Sandbox throughout this tutorial, but any template will work&mdash;including T itself!)

Parameter descriptions
T wouldn't be very interesting if it was only able to generate links. Indeed, the template is more useful than that: it also accepts additional values after the name of the template, which are used to describe its parameters. Let's amend our previous example to include descriptions for  and  :

Note that, for technical reasons, parameter descriptions must occur sequentially. In other words, these will not work:

Sandbox Sandbox

Parameter names
Despite the ominous warning above, there is a way to describe named parameters with T. Simply separate the name and description with the numeric character reference, like so:

Alternately, if you've installed Template:=, then this will do the same thing:

Sandbox

The latter form is preferable, since it doesn't rely on "magic" strings.

Blank descriptions
If you leave the value of a parameter description blank, it will default to. For example:

Literal parameter values
Sometimes when writing documentation, you'll want to talk about what happens when the user supplies a specific value to a parameter, rather than describing the parameter as a whole. You can do this in T by wrapping the value in single or double quotes, like so:

Empty values are also possible:

Note that the whole value needs to be in quotes, so this won't work:

this is "still" a parameter description

Escaping
T doesn't provide any means of escaping special characters like quotes. As with all other wikitext, you can use  tags instead. For example:

Flags
T allows you to modify how it behaves by enabling or disabling special flags. Each flag has both a longhand and a shorthand form, which are listed in the table to the right.

Enabling the  flag switches T from transclusion mode, which describes a template, to invocation mode, which describes a module. These two modes are very similar, the only difference being that the latter requires the name of a function to call. For example, here's how you would link to Module:Sandbox:

Enabling the  flag forces T to put each parameter, as well as the opener and closer, on its own line. For example:

As a module
You can also use T from within another Lua module! They're largely similar, but there are a few differences to be aware of:


 * There is a separate function for each mode, rather than defaulting to transclusion mode and using flags to switch to others.
 * Arguments must be passed in the following order:
 * Any required data, e.g. the template name in transclusion mode
 * (Optional.) A sequential table with parameters
 * (Optional.) A table with options, e.g. the  flag
 * Shorthand flag names are not available, in order to be more explicit.
 * You can use a literal equals sign to separate parameter names from their descriptions (or values).

Here's are a few examples of the Lua syntax:

Generator for transclusion syntax, e.g..

Signature
(title: string, params: Sequence < string >  | nil, options: Options | nil) -> string

Parameters

 * The name of the template to link to, without the namespace prefix.
 * The name of the template to link to, without the namespace prefix.


 * (Optional.) A sequentual table of parameters, as described above.
 * (Optional.) A sequentual table of parameters, as described above.


 * (Optional.) A table with configuration flags, as described above.
 * (Optional.) A table with configuration flags, as described above.

Generator for invocation syntax, e.g..

Signature
(title: string, func: string, params: Sequence < string >  | nil, options: Options | nil) -> string

Parameters

 * The name of the module to link to, without the namespace prefix.
 * The name of the module to link to, without the namespace prefix.


 * The name of the function to call.
 * The name of the function to call.


 * (Optional.) A sequentual table of parameters, as described above.
 * (Optional.) A sequentual table of parameters, as described above.


 * (Optional.) A table with configuration flags, as described above.
 * (Optional.) A table with configuration flags, as described above.

Entry point from the wikitext side. Determines which generator to use based on the provided arguments.

Signature
(frame: Frame) -> string

Parameters

 * A frame object whose arguments will determine the correct generator to use.
 * A frame object whose arguments will determine the correct generator to use.