String template Syntax

Syntax

Description

Example

<attribute>

Replaced with value of attribute.ToString() (or empty string if missing).

<user>

<attribute.property>

Replaced with value of property of attribute (or empty string if missing).

<user.name>

<attribute.(expr)>

Indirect property lookup. Same as attribute.property except value of expr is the property name.

<user.(name_label)>

<multi-valued-attribute>

Concatenation of ToString() invoked on each element.

<users>

<multi-valued-attribute; separator=expr>

Concatenation of ToString() invoked on each element separated by expr.

<users; separator=", ">

<template(argument-list)>

Include (i.e. call) template. argument-list is a list of attribute assignments of the form arg-of-template=exprexpr is evaluated in the context of the surrounding template not of the invoked template.

<bold(item=title)>

<attribute:template(argument-list)>

Template application. The optional argument-list is evaluated before application. The default attribute it is set to the value of attribute. If attribute is multi-valued, it is set to each element in turn and template is invoked n times where n is the number of values in attribute.

<name:checkoutReceipt(items=skus, ship=shipOpt)>

<attribute:{argument-name_ | _anonymous-template}>

Apply an anonymous template to each element of attribute. Set the argument-name to the iterated value and also set it.

<users:{s|<li>$s$</li>}; separator="\n">

<if(!attribute)>subtemplate<endif>

If attribute has no value or is a bool object that evaluates to false, include subtemplate. These conditionals may be nested.

<if(users)> <users:{u|<u>}> <endif>

\$ or \<

escaped delimiter prevents $ or < from starting an attribute expression and results in that single character.

\<

<\ ><\n><\t><\r>

special characters: space, newline, tab, carriage return.

<\n>

<! comment !>$! comment !$

Comments, ignored by StringTemplate.

<! this is a comment !>