Referencing up the hierarchy

So far we’ve looked at referencing a field which is in the same editable element as the reference to it.

<modulezone name="my_modulezone">
  <module name="my_module">
    <field name="my_module_field"></field>
      <editable name="heading">
        <field name="header_text"></field>
        <content replace="{{header_text}}">Hello</content>
      </editable>
  </module>
</modulezone>

To reference a field which is declared outside of an editable but inside the same module the field name needs to be prefixed with module:

module.my_module_field

If the variable is referenced inside the module tag, but outside of the editable tag, then just the ‘my_module_field’ part of the name is needed. Similarly fields which belong at the modulezone level are prefixed with modulezone and document level fields are prefixed with document.

module.my_module_field
modulezone.my_modulezone_module_field
document.my_document_field

Every field and reference has a scope. The scope of an element is the level at the heirarchy at which it lives. The scope is always either:

  • editable
  • module
  • modulezone
  • document

When a reference has in the same scope as the field, only the field name needs to be used.

Referencing down and across the hierarchy

Any field can be referenced from anywhere in a taxi template. The language has been designed so that the most usual use cases have the shortest names.

The singular forms of ‘module’ and ‘modulezone’ are short hands for ‘this module’ and ‘this modulezone’. To use a different modulezone or module or editable the plural form is used and a name must be specified.

Some examples:

modules.first_module.my_module_field
modulezones.header_modulezone.my_modulezone_field
modules.second_example_module.editables.title.title_text
editables.title.title_text

In the last example we’ve not specified which module the editable is in. Taxi will know we mean the same module as the reference.


Next: Using rules to change HTML structure based on content