General Syntax
- Curly braces
{}are used as delimiters. - Every construct is an element
{element}with optional arguments{element arguments}separated by whitespace and an optional closing tag{/element}. - A leading
#indicates a referenceable fragment ID{#whatever}within the rendering context. - A leading
$indicates a variable{$whatever}, optionally followed by whitespace-separated filters with arguments enclosed in parentheses, for example{$whatever filter(arguments) filter}.
Composition Elements
fragment, include, and extends are reserved element names and cannot be
redefined in configuration.
Fragment Element
{fragment #whatever}
// fragment content
{/fragment}
// reference fragment
{#whatever}
// provide fallback content if no fragment exists
{#whatever}
// fallback content
{/whatever}
Include Element
The include element renders another template at its position in the current
template.
{include template}
{include nested/template}
Template references are relative to the mapped templates directory and omit the
.mosaic.php file extension. For example:
- Absolute file path:
/mapped/templates/dir/in/metadata/template.mosaic.php - Template argument:
template
Extends Element
The extends element defers another template for subsequent rendering.
{extends template}
{extends nested/template}
Template references are relative to the mapped templates directory and omit the
.mosaic.php file extension. For example:
- Absolute file path:
/mapped/templates/dir/in/metadata/template.mosaic.php - Template argument:
template
Statement Elements
If Element
{if $whatever > 3}
// conditional content
{elseif $whatever == 3}
// alternative content
{else}
// fallback content
{/if}
Switch Element
{switch $whatever}
{case "whatever"}
// conditional content
{break}
{case "any"}
// alternative content
{break}
{default}
// fallback content
{/switch}
Loop Elements
Foreach Element
{foreach $whatever as $item}
// loop content
// next
{continue}
{continue 2}
// stop
{break}
{break 3}
{/foreach}
For Element
{for $i = 0; $i < 10; ++$i}
// loop content
// next
{continue}
{continue 2}
// stop
{break}
{break 3}
{/for}
While Element
{while $whatever}
// loop content
// next
{continue}
{continue 2}
// stop
{break}
{break 3}
{/while}
continue and break support optional nesting levels, following PHP loop behavior.
Variable Element
Variables can be output directly or passed through one or more output filters. Filters are applied from left to right, with the leftmost filter applied first.
{$variable} // follows global escape configuration
{$variable raw} // do not escape
{$variable escape} // escape
{$variable first second(arguments) third}
Raw Element
The raw element outputs its content without processing template syntax or
applying automatic escaping.
{raw}
// take this content as it is
{/raw}