with: Controls DTML variable look up

The with tag pushes an object onto the DTML namespace. Variables will be looked up in the pushed object first.


with tag syntax:

      <dtml-with Variable|expr="Expression">

The with tag is a block tag. It pushes the named variable or variable expression onto the DTML namespace for the duration of the with block. Thus names are looked up in the pushed object first.


Limits the DTML namespace to only include the one defined in the with tag.
Indicates that the variable or expression is a mapping object. This ensures that variables are looked up correctly in the mapping object.


Looking up a variable in the REQUEST:

      <dtml-with REQUEST only>
        <dtml-if id>
          <dtml-var id>
          'id' was not in the request.

Pushing the first child on the DTML namespace:

      <dtml-with expr="objectValues()[0]">
        First child's id: <dtml-var id>

See Also

let tag