• News
  • Developer information
  • Projects & contributions
  • Forum
  • Issue tracker
  • Open Funding
  • Security
  • User groups
  • Support
  • Store
  • Company

  • Path

    ez.no / exponential / documentation / development / libraries / ez template / basics / operators


    Operators

    These documentation pages are no longer maintained. Please visit the new documentation site.

    Operators allow the template engine to modify variable types or create new values. Operators receive data input from the left and output the result to the right. How the operator modifies the data is up to each operator. For instance, some operators behave differently depending on whether the input data is an array or not, while others may ignore the input and create an output variable.

    The operators can also take extra parameters separated by ',' (comma) and enclosed in '(' and ')' (brackets). The parameters can be constants, variables or operators which means that you can nest operators. For instance, there's no builtin syntax for creating booleans or arrays, instead you use an operator. true() creates a boolean with a true value and false() creates a boolean with a false value. array() takes all its parameters and creates an array out of it.

    The general syntax for an operator is: {input|operator(parameter1,parameter2...)} Remember that both the input and the parameters can be operators. You could for instance write: {cond($b|ne(0),div($a,$b),0)} This example will divide $a by $b and return the result. If $b is null, however, it will not attempt to divide, and return null instead.

    If you want to send input to the operator, then the input and the operator must be separated by '|' (the pipe symbol). If for instance you are calling an operator that takes three parameters, and you want to omit the second parameter, just write nothing at that position, e.g. {operator(parameter1,,parameter2)}.

    Some operators work only on the logical level, meaning that they only see values as true or false. For consistency, all operators should follow these following rules: Arrays are true if the count is larger than 0, numerical values are true if the value is different than 0, booleans behave as normal, null is always false and all other values are false.

    Examples of some variable operators:

    {* Creating and showing an array *}
    
    {array(1,5,'test')|attribute(,,show)}
    
     
    
    {* Multiple serialized operators *}
    
    {array(1,2)|gt(1)|choose('Tiny array','Greater than one')}
    
    {* This will output 'Greater than one', because the array
    
    consists of more than one element.*}

    Comments

    Contents

    Development

    Extensions
    Exponential datamodel
    Exponential tuning and stability
    Importing attribute data
    Kernel
    Libraries
        eZ xml
        eZ db
        eZ i18n
        eZ soap
        eZ template
           Basics
              Functions
              Operators
              Attributes
              Comments
              Namespaces
           Functions
           Operators
        eZ webdav
    Scripting
    Standards
    System overview
    Test Suite
    Using Doxygen to create API documenta...


    Created

    07/07/2003
    3:28:33 pm
    by Bård Farstad

    Last updated

    07/07/2003
    3:28:33 pm
    by Bård Farstad

    Authors

    Bård Farstad



    This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.