Expressions syntax

Template expressions respect a defined syntax:

expression is:
{ conditional_expression
  | unary_op expression 
  | expression op expression
  | expression_as_string in expression_as_string
  |  [ argument_list ] 
  | ( expression )
  | fct ( argument_list )
  | template_path 
  | numeric 
  | boolean 
  | string
  | built-in
  |  null 
  |  undefined
}
where
Note:
  1. conditional_expression returns a value according to the result of a condition expression
    boolean_expression ? if_true : if_false
    If the boolean_expression results in true, the conditional_expression returns the if_true expression, otherwise if_false is returned.
    orientation=='horizontal'?'':' gRadioGroupVertical'  
    # produces an empty string if orientation equals 
    # horizontal, otherwise returns gRadioGroupVertical
  2. expression_as_string is a string
  3. [ argument_list ] defines an array
    [ 1, 2, 'a', 'b' ]      # defines an array with 4 elements
  4. ( expression ) defines a priority in the processing of the expressions.
    (a + b) * c             # means expression 'a + b' will be processed 
                         # before the result is multiplied by c
  5. fct is any valid function name

  6. string is a string value
  7. built-in is a string value
    <div class="gContainer" gwc:attributes="class _tpl_+' gTag'+tag"> 
    will produce
    <div class="gContainer gTagMYTAG"> 
    assuming tag has MYTAG as value
    The built-in expression _tpl_ gets the previous value of an attribute before it is changed by the gwc:attributes instruction. In this snippet, _tpl_ refers the class attribute value, that is: gContainer.
  8. numeric is a numeric value
  9. expression_as_string is any template expression resulting in a string value
  10. template_path is any valid template path
  11. null expression removes a corresponding attribute
    title comment || null;  # if comment attribute is not an empty string 
                            # then set comment value to title otherwise 
                            # remove the html attribute title 
  12. undefined is the value returned by a template path when the path is not available. It is used to make the difference between a template path that would return an empty string and a path that does not exist in the current context.
  13. The + operator can be used with string values to concatenate two strings. Other operators will not work unless string values evaluate to numeric expressions:
    'This expression ' + 'works'
    '12' - '34'                       # works
    '12' - 'ab'                       # doesn't work
  14. The boolean operators && and || behave like their JavaScript™ equivalent. The following table gives the result of the expression:
    expr_A op expr_B
    Table 1. Boolean operators results
    Operator expr_A is TRUE* expr_B is FALSE*
     &&
    expr_B false
     ||
    expr_A expr_B

    *Evaluation is done like the test made by the gwc:condition instruction

    1 > 0 && 'expr_A is true'         # produces expr_A is true
    1 < 0 && 'expr_A is false'        # produces 0
    1 < 0 || 'expr_A is false'        # produces expr_A is false
    As the && operator's priority is greater than the || operator's priority, you can combine these operators to have an if … then … else … statement :
    condition_expr && expr_if_true || expr_if_false
    true  && 'bill' || 'bob'          # produces bill 
    false && 'bill' || 'bob'          # produces bob
  15. The in operator is used to look for a string value in a string value list. Elements of the list are separated by a space character

    'bill' in 'bob bill john'         # produces true