<img src="../files/images/webdesign.gif" width="405" height="144">

Parkland College > Fine & Applied Arts > Graphic Design | Web Design >
Student Links > GDS 214 > Dreamweaver Templates

 

GDS 214 WEB DESIGN II
Dreamweaver Templates - Page 13
Instructor: Rob Higgins

1 > 2 > 3 > 4 > 5 > 6 > 7 > 8> 9 > 10 > 11 > 12 > 13

Back to Start >

 

Checking template syntax

Dreamweaver automatically checks the template syntax when you save a template. An error message dialog appears if the syntax is badly formed. The error message describes the error and refers to the specific line in the code where the error exists.

You can use the Check Template Syntax command to check the template syntax prior to saving a template. For example, if you manually add a template parameter or expression in Code view, use the command to check that the code follows correct syntax.

To check for valid template syntax, do the following:
Choose Modify > Templates > Check Template Syntax.

 

 

Writing a template expression

Template expressions are statements you use to compute or evaluate a value. You can define expressions in Code view or in the Optional Region dialog box.

There are two ways to define expressions in code: using the <!-- TemplateExpr: expr = “your expresson”--> comment, or @@your expression@@. You insert the expression in the template. When you apply the template, Dreamweaver evaluates the expression and displays the value in the template-based document.

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 @@ParamA@@, 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, it is evaluated as true or false. If the condition is true, the optional region will show; if it is false it won’t.

You can write basic template expressions using the Insert Optional Region command; for information about inserting optional regions, see Inserting an optional region. You can define more complex conditions, such as a multiple-if condition or a computed text condition, directly in Code view. To see a multiple-if code example, see Creating a Multiple If condition.

When you write a template expression in the code, an expression marker appears in Design view. To edit the expression in Design view, select the marker and in the Property inspector modify your entry.

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:

@@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 Expression Object Model for the defined variables)
    field reference (the "dot" operator)
  • unary operators: +, -, ~, !
  • binary operators: +, -, *, /, %, &, |, ^, &&, ||, <, <=, >, >=, ==, !=, <<, >>
  • conditional operator: ?:
    parentheses: ()


The following types are used: boolean, IEEE 64-bit floating point, string, and object. The only objects available are those defined by the About the Expression Object Model.

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.

 

 

 

Template tag syntax

Following are the general syntax rules and a list of the comment tags used to define template and template instances (documents) regions. Dreamweaver automatically inserts template tags in the code when you insert a template object. If you prefer to add your own template regions you can enter them directly in Code view.

General rules:
Wherever a space appears, you can substitute any amount of whitespace (spaces, tabs, line breaks). The whitespace is mandatory except at the very beginning or end of a comment.

Attributes can be given in any order. For example, in a TemplateParam, you can specify the type before the name.

Comment and attribute names are case sensitive.

All attributes must be quoted. Single or double quotes can be used.

Template tags:

The following tags define template regions:

<!-- TemplateBeginEditable name="..." -->
<!-- TemplateEndEditable -->

<!-- TemplateParam name="..." type="..." value="..." -->

<!-- TemplateBeginRepeat name="..." -->
<!-- TemplateEndRepeat -->

<!-- TemplateBeginIf cond="..." -->
<!-- TemplateEndIf -->

<!-- TemplateBeginPassthroughIf cond="..." -->
<!-- TemplateEndPassthroughIf -->

<!-- TemplateBeginMultipleIf -->
<!-- TemplateEndMultipleIf -->

<!-- TemplateBeginPassthroughMultipleIf -->
<!-- TemplateEndPassthroughMultipleIf -->

<!-- TemplateBeginIfClause cond="..." -->
<!-- TemplateEndIfClause -->

<!-- TemplateBeginPassthroughIfClause cond="..." -->
<!-- TemplateEndPassthroughIfClause -->

<!-- TemplateExpr expr="..." --> (equivalent to @@...@@)

<!-- TemplatePassthroughExpr expr="..." -->

<!-- TemplateInfo codeOutsideHTMLIsLocked="..." -->

Instance tags:

The following tags define template-based document regions:

<!-- InstanceBegin template="..." codeOutsideHTMLIsLocked="..." -->
<!-- InstanceEnd -->
<!-- InstanceBeginEditable name="..." -->
<!-- InstanceEndEditable -->
<!-- InstanceParam name="..." type="..." value="..." passthrough="..." -->
<!-- InstanceBeginRepeat name="..." -->
<!-- InstanceEndRepeat -->
<!-- InstanceBeginRepeatEntry -->
<!-- InstanceEndRepeatEntry -->

 

1 > 2 > 3 > 4 > 5 > 6 > 7 > 8> 9 > 10 > 11 > 12 > 13

Back to Start >

 

______________________________

Last updated: 6/28/02 • Webmaster: Paul Young

 

 

Tips, Tricks
& Handouts

Student
Links