include

An article by Gaspard Bucher

Include another template or some ancestor (recursion).

  1. action
  2. ajax
  3. API
  4. classes
  5. common attributes
  6. conditions
  7. context
  8. dates
  9. display
  10. forms
  11. i18n
  12. meta
    1. debug
    2. default
    3. headers
    4. include
    5. not_found
    6. possible_roles
    7. roles
    8. with
  13. SQLiss
  14. urls

Include another template or some ancestor (recursion).

  • template path to template to be included
  • part only include a small section
  • depth maximal recursion depth (recursion only)
see name, with, zena 1.0

The include tag has two different roles: pre-processing and recursion.

pre-processing

You can include sub-templates inside a given template and/or specialize some parts of the included template. Usually, you work by including “Node” template and specialize some parts to show a “Letter”, a “Project”, etc. Example:

<r:include template='Node'>
  <r:with part='title'/> <!-- remove title -->
  <r:with part='content'>
    ... specialize content view
  </r:with>
</r:include>

You can also use it in a more traditional “partial” inclusion mechanism:

Include everything:

<r:include template='comments'/>

Or include just some part of a template:

<r:include template='Node' part='related'/>

See name for information on how to name parts.

recursion

If you include a “part” without specifying a template, the part is searched in the ancestors and produces recursion:

<r:void name='grp'>
  <r:parent>
    <r:include part='grp'/> /
  </r:parent>
  <r:show attr='title'/>
</r:void>

The example above produces the following result (whitespace removed) when run from “status” :

Zena the wild CMS / projects list / Clean Water project / status title

You can augment the allowed recursion depth with depth parameter, but you won’t be allowed to go further then 30.