beautypg.com

Template parameters, Template expressions, Template expression language – Adobe Dreamweaver CS3 User Manual

Page 397

background image

DREAMWEAVER CS3

User Guide

390

Template parameters

Template parameters indicate values for controlling content in documents based on a template. Use template param-
eters for optional regions or editable tag attributes, or to set values you want to pass to an attached document. For
each parameter, you select a name, a data type, and a default value. Each parameter must have a unique name that is
case sensitive. They must be one of five permitted data types: text, boolean, color, URL, or number.

Template parameters are passed to the document as instance parameters. In most cases, a template user can edit the
parameter’s default value to customize what appears in a template-based document. In other cases, the template
author might determine what appears in the document, based on the value of a template expression.

Note: A related useful article is available online at http://www.adobe.com/devnet/dream-
weaver/articles/template_parameters.html.

See also

“Using optional regions” on page 402

“Defining editable tag attributes” on page 404

Template expressions

Template expressions are statements that compute or evaluate a value.

You can use an expression to store a value and display it in a document. For example, an expression can be as simple
as the value of a parameter, such as

@@(Param)@@

, or complex enough to compute values which alternate the

background color in a table row, such as

@@((_index & 1) ? red : blue)@@

.

You can also define expressions for if and multiple-if conditions. When an expression is used in a conditional
statement, Dreamweaver evaluates it as

true

or

false

. If the condition is true, the optional region appears in the

template-based document; if it is false, it doesn’t appear.

You can define expressions in Code view or in the Optional Region dialog box when you insert an optional region.

In Code view, there are two ways to define template expressions: use the

comment or

@@(your expression)@@

. When you insert the expression in the template code, an

expression marker appears in Design view. When you apply the template, Dreamweaver evaluates the expression and
displays the value in the template-based document.

See also

“Template expression language” on page 390

“Multiple If condition in template code” on page 391

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)

September 4, 2007