Dreamweaver

Template expression language

The template expression language is a small subset of JavaScript, and uses JavaScript syntax and precedence rules. Use JavaScript operators to write an expression like this:

@@(firstName+lastName)@@

The following features and operators are supported:

  • numeric literals, string literals (double-quote syntax only), Boolean literals (true or false)

  • variable reference (see the list of defined variables later in this section)

  • field reference (the “dot” operator)

  • unary operators: +, -, ~, !

  • binary operators: +, -, *, /, %, &, |, ^, &&, ||, <, <=, >, >=, ==, !=, <<, >>

  • conditional operator: ?:

  • parentheses: ()

    The following data types are used: Boolean, IEEE 64‑bpc floating point, string, and object. Dreamweaver templates do not support the use of JavaScript “null” or “undefined” types. Nor do they allow scalar types to be implicitly converted into an object; thus, the expression "abc".length would trigger an error, instead of yielding the value 3.

    The only objects available are those defined by the expression object model. The following variables are defined:

    _document
    Contains the document-level template data with a field for each parameter in the template.

    _repeat
    Only defined for expressions which appear inside a repeating region. Provides built‑in information about the region:

    _index
    The numerical index (from 0) of the current entry

    _numRows
    The total number of entries in this repeating region

    _isFirst
    True if the current entry is the first entry in its repeating region

    _isLast
    True if the current entry is the last entry in its repeating region

    _prevRecord
    The _repeat object for the previous entry. It is an error to access this property for the first entry in the region.

    _nextRecord
    The _repeat object for the next entry. It is an error to access this property for the last entry in the region.

    _parent
    In a nested repeated region, this gives the _repeat object for the enclosing (outer) repeated region. It is an error to access this property outside of a nested repeated region.

    During expression evaluation, all fields of the _document object and _repeat object are implicitly available. For example, you can enter title instead of _document.title to access the document’s title parameter.

    In cases where there is a field conflict, fields of the _repeat object take precedence over fields of the _document object. Therefore, you shouldn’t need to explicitly reference _document or _repeat except that _document might be needed inside a repeating region to reference document parameters that are hidden by repeated region parameters.

    When nested repeated regions are used, only fields of the innermost repeated regions are available implicitly. Outer regions must be explicitly referenced using _parent.