Genshi templates - header/footer templates, and including templates.

How to include a Genshi template inside of another genshi template?

Use "py:match" inside the template you want to include into other pages (eg. a sitelayout.html).

Then you can use "xi:include" in the pages you want the files included in. (eg. best_picture_of_my_cat_today.html)

Now, it's not a "simple include this template here" kind of thing. The py:match can find various parts of the file, and then replace them how they like. For example, a page layout template will match the header and footer with "py:match".

It is best explained with examples, and in the documentation:
  • pylons genshi example
  • Includes section of the genshi documentation where it explains "xi:include".
  • Genshi documentation where it explains py:match.


  • Hopefully this explains the genshi way of including a template into a template.

    Comments

    Aigars Mahinovs said…
    The easiest way to see it done right is to pick up TurboGears 2.x and start a sample project there.

    Popular posts from this blog

    Draft 3 of, ^Let's write a unit test!^

    Is PostgreSQL good enough?

    post modern C tooling - draft 6