Template Syntax
Smart Variables renders macro content with a Handlebars-compatible template engine. That means you're not limited to dropping in a single variable like {{page.title}} β you can also use Handlebars' block helpers to add conditionals, loops, and formatting logic to your content.
If a variable path doesn't exist (for example, a page with no previousVersion), it silently renders as an empty string instead of showing an error.
Conditionalsβ
{\{#if}}β
{\{#if}} β¦ {{else}}β
{\{#unless}}β
Renders the block only when the value is falsy β the inverse of {{#if}}.
Comparisons inside {\{#if}}β
Handlebars conditionals only check truthiness, so use the built-in eq/ne helpers to compare values:
Loopsβ
{\{#each}}β
Iterate over a list, such as the page's full version history. Inside the block, this refers to the current item.
Scoping with {\{#with}}β
{{#with}} changes the context for the block, so you can drop the repeated prefix:
Commentsβ
Text inside a comment is not rendered:
Helper functionsβ
A small set of helper functions are available for use inside {{ }} expressions or as conditionals:
| Helper | Description | Example |
|---|---|---|
eq | Returns true if two values are equal | {{#if (eq page.status "current")}} |
ne | Returns true if two values are not equal | {{#if (ne page.status "archived")}} |
uppercase | Converts a value to upper case | {{uppercase page.title}} |
lowercase | Converts a value to lower case | {{lowercase page.title}} |
formatDate | Formats an ISO date string | {{formatDate page.createdAt "DATE_FULL"}} |
formatDateβ
formatDate takes the date variable and a format. The format can be a Luxon preset name β like DATE_FULL, DATE_SHORT, or DATETIME_FULL β or a custom Luxon format token string, such as "yyyy-LL-dd".
An empty or invalid date input renders as an empty string.