The var tags allows you insert variables into
DTML output.
var tag syntax:
<dtml-var Variable|expr="Expression">
The var tag is a singleton tag. The var tag finds a variable
by searching the DTML namespace which usually consists of current
object, the current object's containers, and finally the web
request. If the variable is found, it is inserted into the DTML
output. If not found, Zope raises an error.
var tag entity syntax:
&dtml-variableName;
Entity syntax is a short cut which inserts and HTML quotes the variable. It is useful when inserting variables into HTML tags.
var tag entity syntax with attributes:
&dtml.attribute1[.attribute2]...-variableName;
To a limited degree you may specify attributes with the entity
syntax. You may include zero or more attributes delimited by
periods. You cannot provide arguments for attributes using the
entity syntax. If you provide zero or more attributes, then the
variable is not automatically HTML quoted. Thus you can avoid HTML
quoting with this syntax, &dtml.-variableName;.
12000 becomes 12,000.absolute_url method.url_quote but also
converts spaces to plus signs.%xx escapes into their single
character values (ie: undoes the effects of url_quote).+
characters with spaces (ie: undoes the effects of url_quote_plus).size attribute listed
above). By default, this is ...Inserting a simple variable into a document:
<dtml-var standard_html_header>
Truncation:
<dtml-var colors size=10 etc=", etc.">
will produce the following output if colors is the string 'red yellow green':
red yellow, etc.
C-style string formatting:
<dtml-var expr="23432.2323" fmt="%.2f">
renders to:
23432.23
Inserting a variable, link, inside an HTML A tag with the entity
syntax:
<a href="&dtml-link;">Link</a>
Inserting a link to a document doc, using entity syntax with
attributes:
<a href="&dtml.url-doc;"><dtml-var doc fmt="title_or_id"></a>
This creates an HTML link to an object using its URL and
title. This example calls the object's absolute_url method for
the URL (using the url attribute) and its title_or_id method
for the title.