`
template which appends a footer to the content of the `` element produced
so far.
An example of another theme page: [https://github.com/chevah/trac-bootstrap-theme/blob/master/templates/theme.html trac-bootstrap-theme's theme.html].
==== Jinja2 theme
Fortunately Jinja2 can do dynamic includes (or extends in this case) as well,
so the same idea can be transposed: have the end user page extend the layout page,
then have the layout page extend whatever has been defined to be the theme page.
The differences with Genshi are subtle: while in both case the control of the
output is delegated to the more generic page, with Jinja2 the parent only controls
what it puts around //blocks//. It can put some default content in these blocks,
but the end user page has the final say about what to do with this default content,
as it can reuse it inside its block (by calling `super()`) or not.
So let's transpose the example.
For as long as we have both template engines coexisting,
we prefix the new Jinja2 templates with a `j`,
so we're now discussing:
- jsearch.html, which extends
- jlayout.html, which extends
- jtheme.html (as this is our default theme page)
In more details, we describe what happens with the
[source:cboos.git/trac/search/templates/jsearch.html jsearch.html] page:
- it starts by //extending// the jlayout.html page:
{{{#!jinja
# extends 'jlayout.html'
}}}
- the [source:cboos.git/trac/templates/jlayout.html jlayout.html] page:
- first **dynamically** //extends// in turn some "theme" page
{{{#!jinja
# extends ('j' + chrome.theme)
}}}
- by default, this will be our
[source:cboos.git/trac/templates/jtheme.html jtheme.html] page:
- it defines a `head` block inside of an otherwise empty `` element;
this means this a "slot" that will be filled by the content
of the `head` block in the extending templates (in this case,
jlayout.html)
- it contains a `` element;
as we want to replicate what the original theme.html did,
what we want to achieve here is to provide a ''slot''
at the place where we want to substitute in the content
produced by the jlayout.html template:
{{{#!xml (shoud really be jinja+html...)
# block body
...
...
# block content
(here goes the content of the content block produced by layout.html)
# endblock content
# block body
}}}
I didn't name that inner block "body", as this could be confusing:
we're not in control of the `` element there, just of
a fraction of it, the bottom part of the main div.
//If// we want to be in complete control of the body in the extended
template, we could (as opposed to what happens in Genshi),
we would simply have to redefine the `body` block which contains
all of the default structure (possibly reusing the content of that
block by a call to `${ super() }`)
- then the jlayout.html template defines the `head` and `content` blocks;
it doesn't need to redefine the `body` block, as it's happy with what
jtheme does with it;
that `content` block is filled with some predefined, generic content,
mostly the same stuff that could be found in the corresponding
`` filters in layout.html;
- the end user template jsearch.html has to redefine the head and content
blocks, and has to place a `${ super() }` expression in order to
insert the default content proposed by the extended template at
the right place
Depending how one looks at it, it seems this approach is even more flexible than
what we had in Genshi, as the end user template can decide which bits of the
parent template it wants or not ("bottom-up" control), something that was not
readily doable with Genshi ("top-down" control).
I omitted the discussion of the title block (not even implemented yet) and the
replacement for the `