Template Properties
Reference
A template declares its properties on the leading lines of its content, one per line, in the form shown below. The engine reads them and removes them from the content, so they never reach the parser:
##!source.syntax=xwiki/2.1
{{info}}
Some info message
{{/info}}| Property | Values | Default | What it does |
|---|---|---|---|
| source.syntax | a rendering input syntax | The parser used to interpret the result of the Velocity execution | |
| raw.syntax | a rendering input syntax | xhtml/1.0 | The syntax of the raw block the result is wrapped in. Ignored when source.syntax is set |
| author | the reference of an XWiki user | The user the template is executed as. Filesystem and classloader templates only | |
| privileged | true or false | true | Gives the filesystem or classloader template programming right, by executing it as xwiki:XWiki.superadmin |
| cacheAllowed | true or false | false | Allows the result of the execution to be cached |
| asyncAllowed | true or false | false | Allows the template to be executed asynchronously |
| contextEntries | a list of context entries | The entries of the execution context the template needs when it is executed asynchronously | |
| unique | REQUEST | Executes the template at most once per request | |
| require.<hint> | depends on the requirement | A condition that must be met before the template is executed |
Template requirements
The part of a require. property after the dot is the hint of a component implementing org.xwiki.template.TemplateRequirement, and its value is whatever that component expects. A hint matching no component is ignored; a requirement that is not met stops the execution, and the template reports the failure instead of running.
XWiki ships one requirement, action, which matches the action of the current request against a Java regular expression:
##!require.action=view|editFAQ
What happens to a name that is not in the table?
It is kept as an untyped property, readable through TemplateContent.getProperty, and nothing in the engine acts on it.
Does a template have to declare any property?
No. A template with no leading property line is executed as Velocity and its result is wrapped in a raw block of xhtml/1.0.