String Interpolation

String interpolation allows any valid expression to appear within a double-quoted string. The result of processing the expression is inserted into the string.

The format for string interpolation is "#{EXPRESSION}". For example:

{{ "Sam #{middleName} Smith" }}

The expression can be a simple variable. It can also be math, filters, or the output of a function. String interpolation can be used when outputting content or when setting a variable.

{{ "One plus two equals: #{1 + 2}" }}
{% set value = "Hello #{name|upper}" %}
{{ "Some random value: #{random_letters()}" }}

String interpolation is an alternative to using the ~ operator to join strings or variables together.

Your code can ignore string interpolations by escaping them with a backslash.

{{ "Hello \#{name}" }}

# This will output: Hello #{name}
This documentation is only for Aptuitiv CMS. Learn more.
Get Started With Aptuitiv