beautypg.com

Template parameters, Template expressions – Adobe Dreamweaver CC 2015 User Manual

Page 476

background image

469

Templates

Last updated 6/3/2015

To have Dreamweaver update document-relative paths to non-template files in the Templates folder, select the
Templates category in the Site Setup dialog box (it’s under Advanced Settings), and deselect the Don’t Rewrite
Document Relative Paths option.

For more information, see the Dreamweaver TechNote on the Adobe website at

www.adobe.com/go/f55d8739

.

Server scripts in templates and template-based documents

Some server scripts are inserted at the very beginning or end of the document (before the tag or after the
tag). Such scripts require special treatment in templates and template-based documents. Normally, if you
make changes to script code before the tag or after the tag in a template, the changes are not copied to
documents based on that template. This can cause server errors if other server scripts, within the main body of the
template, depended on the scripts that are not copied. An alert warns you if you change scripts before the tag
or after the tag in a template.

To avoid this problem, you can insert the following code in the head section of the template:

When this code is in a template, changes to scripts before the tag or after the tag are copied to
documents based on that template. However, you will no longer be able to edit those scripts in documents based on the
template. Thus, you can choose to either edit these scripts in the template, or in documents based on the template, but
not both.

Template parameters

Template parameters indicate values for controlling content in documents based on a template. Use template
parameters 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.

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.