TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pompom454/tea/llms.txt
Use this file to discover all available pages before exploring further.
Template API lets you define named text substitutions, called templates, that can be dropped into any passage using the ?name markup syntax. A template can be a static string, a function that returns a string, or an array of either — in which case one member is chosen at random each time the template is referenced. Templates are ideal for reusable flavor text, procedural descriptions, or name variations.
Template names must start with a letter from the basic Latin alphabet and may be followed by letters, digits, underscores, or hyphens. They are referenced in passage markup as
?templateName (with a leading question mark).Template.size → number
The number of templates currently registered.
Template.add(name, definition)
Registers one or more new templates.
Name, or array of names, to register. Must start with a basic Latin letter, optionally followed by letters, digits, underscores, or hyphens.
The template definition. May be:
- A string — output verbatim each time (may contain markup).
- A function — called with no arguments,
thisset to a context object with anameproperty; must return a string. - An array of strings and/or functions — one member is chosen at random on each reference.
String templates
A string template is output as-is every time it is referenced. The string may itself contain wiki markup.Function templates
A function template is called each time the template is referenced. It receives a context object asthis with a single name property (the template’s registered name) and must return a string.
Array templates
An array template randomly selects one of its members (string or function) each time it is referenced.Template.delete(name)
Removes one or more registered templates.
Name, or array of names, of the template(s) to remove.
Template.get(name) → Function | string | Array<Function | string> | null
Returns the definition for the named template, or null if no template with that name exists.
Name of the template to retrieve.
Template.has(name) → boolean
Returns true if a template with the given name is registered.
Name of the template to check.
Using templates in passage markup
Reference a template in any passage by prefixing its name with?:
?weapon and ?enemy are registered templates, Tea substitutes them inline wherever they appear.
Practical example: character description templates
?hairColor and ?skyDesc resolve to fresh random values.