= [GenshiRecipes Genshi Recipes]: Replacing `py:layout` with Includes =
As noted in GenshiVsKid, Markup does not support the `py:layout` directive for template reuse.
This page shows how the [http://www.kid-templating.org/language.html#layout-templates-py-layout example] from the Kid language specification translates to a functionally equivalent setup in Genshi.
Assume the following layout template, stored as `layout.html`:
{{{
#!xml
App Name - ${page_title}
${page_specific_css}
Now viewing: ${page_title} of App Name
Default content
}}}
And the following page-specific template, stored as `page.html`:
{{{
#!xml
Content Page 1 of 10
Content Item 1
Content Item 2
Content Item 3
}}}
The “trick” here is that the base template is included at the '''bottom''' of the page template. This results in the template functions `page_title()` and `page_specific_css()` being available to the layout template, and the match template defined in the page template being applied to the layout template.
When rendered, the following output would be generated:
{{{
#!xml
App Name - Content Page 1 of 10
Now viewing: Content Page 1 of 10 of App Name
Content Item 1
Content Item 2
Content Item 3
}}}
----
See also: GenshiRecipes/PyExtendsEquivalent, GenshiRecipes, GenshiVsKid, [wiki:Documentation/xml-templates.html Genshi XML Template Language]