Macromedia dreamweaver 8-using dreamweaver Manuel D’Utilisation
306
Chapter 11: Managing Templates
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.
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.
Related topics
■
■
Template expressions
Template expressions are statements you use to 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
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 (for an example, see
). 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. For more information about writing template expressions, see
insert an optional region. For more information about writing template expressions, see
In Code view, there are two ways to define template expressions: use the
<!-- TemplateExpr
expr=“your expresson”-->
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.
apply the template, Dreamweaver evaluates the expression and displays the value in the
template-based document.
The template expression language
The template expression language is a small subset of JavaScript, and uses JavaScript syntax
and precedence rules. You can use JavaScript operators to write an expression like this:
and precedence rules. You can use JavaScript operators to write an expression like this:
@@(firstName+lastName)@@