Edgewall Software

Changes between Version 30 and Version 31 of GenshiTutorial


Ignore:
Timestamp:
Aug 30, 2007, 2:48:30 PM (12 years ago)
Author:
cmlenz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GenshiTutorial

    v30 v31  
    321321</html>
    322322}}}
     323
     324This 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 (`${...}`).
    323329
    324330When you reload the page in the browser, you should see a page similar to this:
     
    744750TODO
    745751
    746 == AJAX-Enabled Comments ==
     752== Ajaxifyied Commenting ==
    747753
    748754TODO