Next Chapter | Up | Next Section | Contents

The name attribute

The name attribute is used to obtain data by name. The data is looked up using the rules described in the section "Name Lookup" below. The name attribute is special since there exists a shortened version of the attribute, as described in the section "DTML Tag Syntax" above.

When the value of a name attribute is looked up, the value is automatically called, if possible. If the value is a Zope Document or Python document template, it is rendered before being given to the tag that uses the name attribute. For example, most Zope documents begin with a dtml- var tag:

<dtml-var standard_html_header>

standard_html_header is a Zope document which provides standard HTML to be included at the top of every page. When the var tag above is used, the DTML in standard_html_header is rendered and the result is inserted in the current document.

If the value of a name attribute is a function3 that is called with no arguments, then the result of the function call is given to the tag using the name attribute.

When the name attribute is used in the dtml- if , dtml- elif , dtml- unless , dtml- in or dtml- with tag, the value associated with the name is cached, causing references to the name in enclosed text to be faster than the initial reference. This is especially useful when the name refers to a function which is expensive to compute. For example:

<dtml-if reallyExpensiveFunction>
<dtml-var reallyExpensiveFunction>

The dtml-var tag uses the cached value for reallyExpensiveFunction . Note that tags, such as dtml-in and dtml-with, which introduce new variables may introduce a new value for the given name, causing the cached value to be overridden.

Next Chapter | Up | Next Section | Contents