HTL Options

HTL Options

Options are used with block statements, Symbol @ starts the option expression. Options can have a value, which may be either a variable or a literal. Options are mainly used for String Formatting, Internationalization, Array Join.

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

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

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

Display Context
 HTL will automatically detect the context of expressions and escape them appropriately to ensure the security and avoid XSS vulnerability. The context behavior may need to be adjusted as our coding needs. This can be explicitly set to override the automatic behavior of HTL. HTL display context refers to its location within the structure of the HTML page.

 Display Context Settings are given below

  •  text
  •  html
  •  attribute
  •  uri
  •  number
  •  attributeName
  •  elementName
  •  scriptToken
  •  scriptString
  •  scriptComment
  •  styleToken
  •  styleString
  •  styleComment
  •  unsafe

  //Safely output the markup
 ${properties.richText @ context='html'}

Go to HTL Tutorial Home page


No comments:

Post a Comment