Expression Syntax
All expressions are enclosed in double curly braces: {{ expression }}.
Literals
| Type | Example |
|---|---|
| String | "Hello, World" |
| String | 'Single quoted' |
| Integer | 42 |
| Float | 3.14 |
| Boolean | true, false |
| Null | null |
Property Access
Use dot notation to access properties on data roots, with certain alias shorthands supported:
{{ user.name }}
{{ post.title }}
{{ post.meta.card_type }}
{{ site.name }}
In addition to dot notation, the engine supports bracket notation. This is essential for accessing properties using a variable key or keys that contain special characters:
{{ user.meta["my-meta-key"] }}
{{ post.meta["card_type"] }}
{{ post.meta[user.name] }}
Comparison Operators
| Operator | Meaning |
|---|---|
== | Equal |
!= | Not equal |
> | Greater than |
< | Less than |
>= | Greater or equal |
<= | Less or equal |
{{ post.comment_count > 0 }}
{{ user.role == "administrator" }}
Logical Operators
| Operator | Meaning |
|---|---|
&& | AND |
|| | OR |
! | NOT |
{{ user.is_logged_in && post.meta.members_only }}
{{ !user.is_logged_in }}
Ternary Expressions
{{ condition ? valueIfTrue : valueIfFalse }}
Example:
{{ user.is_logged_in ? "View Dashboard" : "Sign In" }}
Arithmetic Operators
| Operator | Meaning |
|---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulo |
{{ post.meta.price * 1.1 + 20 }}
Grouping with Parentheses
To control the order of operations in complex logic or math, parentheses are fully supported:
{{ (post.meta.price + 20) * 1.1 }}
{{ (user.is_logged_in || post.status == 'publish') && !post.meta.is_private }}
String Concatenation and Interpolation
Use the + operator to join strings:
{{ "Hello, " + user.display_name + "!" }}
Inside a string literal, users can embed expressions directly using single curly braces:
{{ "Hello, {user.name | upper}!" }}
Modifier Pipeline
Apply transformations to a value using |:
{{ post.author_name | upper }}
{{ "now" | date "F j, Y" }}
Modifiers can be chained — they are applied left to right:
{{ user.display_name | lower | default "anonymous" }}
Modifier Arguments - The library supports both positional and named arguments:
{{ post.meta.card_type | match event="Workshop" course="Academy" | default "Resource" }}
See the Modifier Reference for the complete list.
Complete Expression Examples
{{ user.is_logged_in ? "Welcome back, {user.display_name}" : "Join us today" }}
{{ post.meta.card_type | match event="is-event" course="is-course" default="is-standard" }}
{{ post.author_name | upper }} • {{ post.date | date "F j, Y" }}
{{ ("now" | date "U") + 86400 * 5 | date "F j, Y" }}
Raw Output
By default, all output is HTML-escaped. To output raw HTML, use the raw modifier or the special syntax {{{ ... }}}:
{{ "<h2>hello</h2>" | raw }}
{{{ "<h2>hello</h2>" }}}
Of note:
{{{ }}}syntax is not supported in Gutenberg RichText — use therawmodifier instead.- This bypasses the default htmlspecialchars path. Note that it still runs through wp_kses_post to strip dangerous tags like
- The editor preview will not show the raw output — it will show the escaped output.