ZPT-JS reference - String expressions

Syntax

string_expression      ::= 'string:' string_expression_item
string_expression_item ::= ( plain_string | [ varsub ] )*
varsub                 ::= ( '$' Path ) | ( '${' Path '}' )
plain_string           ::= ( '$$' | non_dollar )*
non_dollar             ::= any character except '$'
                

Description

String expressions interpret the expression string as text. If no expression string is supplied the resulting string is empty. The string can contain variable substitutions of the form $name or ${path}, where name is a variable name, and path is a path expression. The escaped string value of the path expression is inserted into the string. To prevent a $ from being interpreted this way, it must be escaped as $$.

Note: some parts extracted from Zope Page Templates Reference.

Differences with ZPT

None.

Examples

Using {} or not:

<div data-content="string:user is ${user/name}">must be Bob</div>
<div data-content="string:user is $user/name">must be Bob again</div>
                

Escaping $:

<div data-content="string:give me $$${aString} or else">escape the $</div>
                

Note: some parts extracted from Zope Page Templates Reference.