September 24, 2026

HTL Options: Formatting, i18n, Join and Display Context

Options modify an expression. The @ symbol starts the options part, and each option can take a value, which may be a variable or a literal. Options are mainly used for string formatting, internationalization and joining arrays.

String formatting

${'Page {0} of {1}' @ format=[current, total]}

Internationalization

${'Page' @ i18n, hint='Direction for translators', source='user'}

Array join

${['1', '2'] @ join='; '}

Display context

HTL detects the context of each expression automatically and escapes it accordingly, which keeps output secure and prevents XSS. When your code needs different behaviour, you can set the context explicitly to override the automatic one. The display context refers to the expression's location within the structure of the HTML page.

The available display contexts are:

  • text
  • html
  • attribute
  • uri
  • number
  • attributeName
  • elementName
  • scriptToken
  • scriptString
  • scriptComment
  • styleToken
  • styleString
  • styleComment
  • unsafe
<!--/* Safely output the markup */-->
${properties.richText @ context='html'}

Back to the HTL tutorial index