Skip to main content
All CollectionsDynamic Shortcodes
The Syntax of Dynamic Shortcodes
The Syntax of Dynamic Shortcodes
Updated over a year ago

Informal Description

A Dynamic Shortcode is a special text element enclosed in curly braces '{}' . It has a specific structure that allows you to provide arguments, options, filters, and fallback values. Here's a simple guide to help you understand the syntax of a Dynamic Shortcode:

  1. A shortcode starts with an identifier followed by a colon ':'. An identifier is a sequence of letters, digits, or underscores, beginning with a letter.

  2. Then there is a list of arguments separated by spaces, for some shortcodes types this list can also be empty. There are five types of arguments you can use:
    - Identifier: Same as the shortcode's identifier, it's a sequence of letters, digits, or underscores, starting with a letter. For example, {my_shortcode:arg1}.

    - Number: A sequence of digits, e.g., {my_shortcode:42}.

    - Nested string: A sequence of characters enclosed in square brackets [], e.g., {my_shortcode:[nested string]}. Shortcodes will be expanded inside the string.

    - Quoted string: A sequence of characters enclosed in double quotes "", e.g., {my_shortcode:"quoted string"}

    - Dynamic Shortcodes: . You can also insert directly a Dynamic Shortcode
    โ€‹{my_shortcode:{nested_shortcode:}}

  3. You can also provide a list of options by adding an `@` symbol followed by one or more options separated by spaces. Each option can be:

    - An identifier, e.g., {my_shortcode:@option1}.

    - An identifier followed by an equal sign `=` and a value (identifier, number, nested string, or quoted string), e.g., {my_shortcode:@option2=value}.

  4. You can apply filters to the shortcode using filter operators: `|`, `||`, or `|-`. A filter consists of a filter operator, an identifier, and an optional list of values enclosed in parentheses `()` and separated by commas `,`. For example, {my_shortcode|filter1(identifier,value1,value2):}.

  5. Lastly, you can define a fallback value in case the shortcode can't be resolved. To do this, add a question mark `?` followed by a value (identifier, number, nested_string, quoted_string or shortcode). For example, {my_shortcode:?fallback_value}.

Remember, spaces are used to separate arguments and options.


โ€‹

Formal EBNF Description

shortcode = '{', identifier, ':' , [ arguments_list ], [options_list], {filter}, [fallback], '}' ;

arguments_list = value, { space, value } ;

options_list = '@', option, {space, option} ;

option = identifier | identifier, "=", value ;

filter = filter_operator, identifier, [ '(', [ value ], { ',', value } , ')' ];

fallback = '?', value;

value = identifier | number | nested_string | quoted_string ;

quoted_string = '"', { character } , '"' ;

nested_string = '[', { character }, ']';

identifier = letter, { letter | digit | '_' };

number = digit, { digit } ;

character = letter | digit | symbol ;

filter_operator = "|" | "||" | "|-" ;

(*
Basic components
----------------
These are low level components, the small building blocks.
*)

letter = "A" | "B" | "C" | "D" | "E" | "F" | "G"
| "H" | "I" | "J" | "K" | "L" | "M" | "N"
| "O" | "P" | "Q" | "R" | "S" | "T" | "U"
| "V" | "W" | "X" | "Y" | "Z" | "a" | "b"
| "c" | "d" | "e" | "f" | "g" | "h" | "i"
| "j" | "k" | "l" | "m" | "n" | "o" | "p"
| "q" | "r" | "s" | "t" | "u" | "v" | "w"
| "x" | "y" | "z" ;

digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;

symbol = "[" | "]" | "{" | "}" | "(" | ")" | "<" | ">"
| "'" | '"' | "=" | "|" | "." | "," | ";" ;

space = " " ;

Did this answer your question?