Previous Chapter | Next Chapter | Up | Next Section | Contents

Displaying Objects with the dtml-with Tag


The dtml-with tag can be used to expand the namespace of a document template by adding attributes (or mapping keys) from an object which already exists in the document template namespace. For example, if a document template is used to display a folder, the contents of a sub-folder can be displayed using a dtml-with tag:

<dtml-with subfolder>
<dtml-var title>
</dtml-with>

In combination dtml-with the namespace method of the special variable, _, the dtml-with tag can be used to add new variables to the DTML name space:

<dtml-with "_.namespace(profit=price-cost, title=product_name+' summary')">
<h3><dtml-var title></h3>
The profit is <dtml-var profit>
</dtml-with>

A common use of the dtml-with tag is to cause request variables to be used before object attributes:

The current id is <dtml-var id>
<dtml-with REQUEST>
The id you entered was <dtml-var id>
</dtml-with>

Normally, document templates are used as methods of objects. Object attributes commonly take precedence over request variables. Using the REQUEST variable in a dtml-with tag causes the request to be searched before other parts of the name space.

Previous Chapter | Next Chapter | Up | Next Section | Contents

SUBSECTIONS