Template Tag References
Supported template tags are:
- template:attribute
- template:each
- template:href
- template:include
- template:link
- template:text
- template:when
template:attribute
Adds an attribute to the parent element.
Element Attributes
| Name | Description | Required |
|---|---|---|
| name | The name of the attribute to add or modify in the parent | yes |
| eval | The expression to be evaluated by site spec | yes |
Example
<div> <template:attribute name="class" eval="center_class"/> ... </div>
This will generate:
<div class="Column2Center"> ... </div>
template:each
Load the XML document, iterate through a list of selected XML elements and use them as the source to process all children elements.
Element Attributes
| Name | Descrption | Required |
|---|---|---|
| source | Path(relative to content root) or URL of the XML document | yes |
| select | XPath used to select the XML elements | yes |
| count | Number of the selected elements to process | yes |
Example
This is useful for generating list like latest news.
<template:each source="news_rss2" select="/rss/channel/item" count="3"> <div class="NewsItem"> <p class="NewsTitle"><template:include elements="./title/text()"/></p> <p class="NewsDate"><template:include elements="./pubDate/text()"/></p> <p class="NewsText"><template:include elements="./xhtml:div/node()"/></p> </div> </template:each>
template:href
Based on the position of the current file, generate href (for <a> tag) or src (for <img> tag) attribute
that contains the relative path to the target file reference.
Element Attributes
| Name | Description | Required |
|---|---|---|
| url | Path (relative to content roott) or the URL of the referencd link or image | yes |
Example
<img><template:href url="images/logo.gif"/></img>
The above example will generate the following result for the file in <content_root>/doc/help.html
<img src="../images/logo.gif"/>
template:include
Include the element of the current source content file.
Element Attributes
| Name | Descrption | Required |
|---|---|---|
| elements | xpath expression used to select the elements to include | yes |
Example
<template:include elements="/html/head/title/text()"/>
template:link
Generate the <a> tag with correct relative path or URL, or <div class="current"> if the current file is
the referenced file.
Element Attributes
| Name | Description | Required |
|---|---|---|
| href | path (relative to content root) or URL of the link | yes |
Example
<li><template:link href="download.html">Download and Dependencies</template:link></li>
template:text
Generate dynamictext text content.
Element Attributes
| Name | Description | Required |
|---|---|---|
| property | static property set up in site spec | yes |
<template:text property="release"/>
template:when
Conditionally process the children elements.
Element Attributes
| Name | Descrption | Required |
|---|---|---|
| test | expression to evaluate, children will be processed if a true value is returned | yes |
Example
<template:when test="index_file?">