Kauri Documentation
 PreviousHomeNext 
8.4.13 ifBook Index8.4.15 init

8.4.14 include, import

include and import allow to include other template files into the current one, hence supporting modularisation and re-use.

An include/import will cause the included template to be executed at the moment the include/import instruction is encountered. Any output produced by the included/imported template will be inserted at that location.

The difference between include and import is that and import will never override macro definitions from the template it is included in. An include on the other hand behaves as if the content of the included template would be inserted at the location of the include instructions: any macro will override previously defined macro's with the same name.

Syntax
<t:include src="..." mode="..."/>
<t:import src="..." mode="..."/>

Attributes:

Usage

Includes and imports can occur at any location in a template file. They are not only useful for including macro libraries, but also for reusable snippets.

The same template can be included multiple times.

Supress root element trick

If you have a "snippet" template to be included in other templates, but you don't want the template to produce a root element, you can use a t:if element as root for your template:

<?xml version="1.0"?>
<t:if test="${true}" xmlns:t="http://kauriproject.org/template">
  Hello world!
</t:if>
See also

For reusable layouts, be sure to check out the template inheritance feature.

 PreviousHomeNext 
8.4.13 if8.4.15 init