| 323 | |
| 324 | This template demontrates some aspects of Genshi that we've not seen so far: |
| 325 | * We declare the `py:` namespace prefix on the `<html>` element, which is required to be able to add [wiki:Documentation/xml-templates.html#template-directives directives] to the template. |
| 326 | * There's a `py:if` [wiki:Documentation/xml-templates.html#conditional-sections condition] on the `<ol>` element. That means that the `<ol>` and all nested content will only be included in the output stream if the expression `submissions` evaluates to a truth value. In this case we know that `submissions` is a list (assembled by the `Root.index()` method), so if the list is empty, the `<ol>` will be skipped. |
| 327 | * Next up, we've attached a `py:for` [wiki:Documentation/xml-templates.html#looping loop] to the `<li>` element. `py:for="submission in reversed(submissions)"`. What this does is that the `<li>` element will be repeated for every item in the `submissions` list. The `submission` variable is bound to the current item in the list on every step. |
| 328 | * You can tell that we can also use more complex expressions than just simple variable substitutions: the directives such as `py:if` and `py:for` take Python expressions of any complexity, while you can include complex expressions in other places by putting them inside curly braces prefixed with a dollar sign (`${...}`). |