The syntax of template expressions closely resembles that of JavaScript, and both use a
similar dot notation to refer to the properties of a specific object. Similar to JavaScript, Dreamweaver template
expressions also have their own object model, although the object model for template expressions is
much more limited in scope.
The elements supported by Dreamweaver template expressions are detailed in Table 28-1.
CAUTION CAUTION
892
Enhancing Productivity and Web Site Management Part VI
FIGURE 28-14
Template expressions can either be entered as statements or inline code.
TABLE 28-1
Template Expression Features and Operators
Literals Syntax Example
Numeric Literal Double-quoted numbers ???123???
String Literal Double-quoted string ???Chapter???
Boolean Literals true/false true
String Concatenation string1 + string2 ???Number of rows: ??? + _numRows
Ternary Operator
Conditional condition ? resultA : resultB (_index & 1) ? #FFFFFF : #CCCCCC
Logical Operators
Logical NOT !operand !mainLogoRegion
Logical AND operand1 && operand2 onSale && nowFeatured
Logical OR operand1 || operand2 onSale || nowFeatured
Inline template expression
893
Using Dreamweaver Templates 28
TABLE 28-1 (continued)
Literals Syntax Example
Arithmetic Operators
Addition operand1 + operand2 _numRows + 1
Subtraction operand1 ??“ operand2 _index ??“ 1
Multiplication operand1 * operand2 basePrice * taxBase
Division operand1 / operand2 numSold / quantityShown
Modulo operand1 % operand2 _index % 2
Comparison Operators
Less Than operand1 < operand2 inStock < numSold
Greater Than operand1 > operand2 numSold > numShipped
Less Than or Equal operand1 <= operand2 _index <= _numRows
Greater Than or Equal operand1 >=operand2 _numRows >= pageLimit
Equal operand1 == operand2 _index == 10
Not Equal operand1 != operand2 _numRows != 1
Bitwise Operators
Bitwise NOT ~operand ~4
Bitwise AND operand1 & operand2 _index & 1
Bitwise OR operand1 | operand2 4 | 8
Bitwise XOR operand1 ^ operand2 2 ^ 4
Bitwise Signed Right Shift operand1 >> n 8 >> 1
Bitwise Left Shift operand << n 1 << 0
The template expressions document model is made up of two primary objects: _document and _repeat.
Pages:
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533