Available Processing Directives
Here’s a list of all the Template Directives in Genshi, along with a brief description.
Genshi Directive Definition:
py:if Displays the element and its children if the condition is true.
py:choose Used with py:when and py:otherwise to select one of several options to be rendered.
py:when Used with py:choose – displays an element and its children when the condition is true.
py:otherwise Used with py:when and py:choose, displays if non of the when clauses are true.
py:for Repeats the element (and its children) for each item in some iterable
py:with Lets you assign expressions to variables
py:replace Replaces the element with the contents of the expression, stripping out the element itself.
py:strip Removes just the containing element (not its children) if the condition is true.
py:match given an XPath expression, it finds and replaces every element in the template that matches the expression – with the content of the element containing the py:match.
There are examples of how each of these template directives works on the Genshi web site.
py:def Creates a re-usable “template function” that can be used to render template snippets based on the arguments passed in.