Spintax Syntax Reference
Complete reference for spintax template markup. The syntax is compatible with the Generating The Web (GTW) standard.
Enumerations { }
Randomly selects one option from the list.
{option1|option2|option3}
Examples
{blue|grey|clear}
{|online|internet} casino ← empty option = sometimes nothing
{1X{S|s}lots} ← nested enumerations
{license {|#8048} from Curacao} ← nesting with empty option
Rules
- Delimiters:
{and} - Separator:
| - Supports nesting to arbitrary depth
- Empty options are valid (produce empty string)
- Resolution is from the innermost expression outward
Permutations [ ]
Selects N elements, shuffles them, and joins with separators.
Simple permutations
All elements included, space-separated:
[1|2|3|4]
Output examples: 1 4 3 2, 2 3 4 1, 3 2 4 1
With separator
Uniform separator specified in < > at the start:
[<, > 1|2|3|4]
Output examples: 2, 1, 4, 3, 4, 3, 2, 1
Important: No space between [ and <separator>.
Per-element separators
Each option can have its own separator defined with <sep> before the preceding |:
[<, > 1|2|3 < and >|4]
Output examples: 1, 3, 2 and 4, 3, 1, 2 and 4
Permutations with combinations
Configurable min/max element count and separators:
[<minsize=1;maxsize=3;sep=", ";lastsep=" and "> apple|plum|orange|apricot]
Output examples: apple, plum and orange, apple and apricot, orange
Configuration parameters
| Parameter | Default | Description |
|---|---|---|
minsize | count of all | Minimum number of elements to pick |
maxsize | count of all | Maximum number of elements to pick |
sep | " " (space) | Separator between non-final items |
lastsep | same as sep | Separator before the last element |
Permutation rules
- Delimiters:
[and] - Config block
<...>must immediately follow[ - Config parameters are semicolon-separated
- String values in config are quoted:
sep=", " - Enumerations and permutations can be nested inside options
- HTML elements can be options
Variables %var%
Defines a reusable variable that is substituted wherever it appears.
#set %VARIABLE_NAME% = value or spintax structure
Examples
#set %name% = John
#set %greeting% = {Hello|Hi|Hey}
#set %items% = [<minsize=2;maxsize=3;sep=", ";lastsep=" and "> apples|oranges|bananas]
Some text with %name% and %greeting%, also %items%.
Variable rules
#setmust start at the beginning of a line- Variable names are enclosed in
%:%name% - Variable names are alphanumeric + underscore
- Values can contain any spintax syntax (enumerations, permutations, other variables)
- Variables are expanded when referenced, not when defined (lazy evaluation)
#setlines are stripped from output
Variable scopes in the WordPress plugin
The plugin supports three variable scopes. When the same name exists in multiple scopes, the strongest scope wins:
- Runtime variables (strongest) — passed via shortcode:
[spintax slug="greeting" name="Alice"] - Local variables — defined with
#setinside the template - Global variables (weakest) — defined on the Settings page
Includes #include
Embeds another template at the directive's position.
#include "hero-text"
Include rules
- Template reference is in double quotes
- Resolves by template slug or numeric ID
- Included templates can contain their own variables and spintax
- Recursive includes are supported
- Circular references are detected and blocked
- Child templates inherit global and runtime variables but not parent's
#setlocals
Comments /#...#/
Text between comment markers is stripped from the output before any other processing.
/#
This is a comment section.
It can span multiple lines.
It won't appear in output.
#/
Comment rules
- Start delimiter:
/# - End delimiter:
#/ - Can span multiple lines
- Cannot be nested
- Removed before any other processing
Nesting
All syntax elements can be nested within each other to arbitrary depth:
{option1|[<, > sub1|sub2|sub3]|option3}
[<minsize=2;maxsize=3;sep=", ";lastsep=" and "> {red|blue} apples|{big|small} oranges|bananas]
#set %var% = {a|[b|c]}
Post-Processing
The engine applies automatic text correction after generation:
- Shield URLs, emails, domains, decimals, and abbreviations from capitalization
- Collapse duplicate spaces and tabs
- Remove whitespace before punctuation (
,.!?) - Add space after punctuation where missing
- Capitalize first letter of the output (skipping HTML tags)
- Capitalize after sentence-ending punctuation
- Capitalize after block-level HTML tags
- Capitalize after line breaks
- Restore shielded placeholders
Syntax Summary
| Feature | Syntax | Behavior |
|---|---|---|
| Enumeration | {a|b|c} | Pick one random option |
| Permutation | [a|b|c] | Pick N, shuffle, join |
| Separator | [<sep> a|b|c] | Permutation with uniform separator |
| Per-element sep | [<,> a|b <x>|c] | Permutation with custom separators |
| Combinations | [<config> a|b|c] | Permutation with min/max count |
| Variable | #set %var% = val | Reusable substitution |
| Include | #include "slug" | Embed another template |
| Comment | /#...#/ | Stripped from output |
The syntax is compatible with the Generating The Web (GTW) standard.