{{{#!div class="important" style="border-radius: .3em; text-align: center; padding: 0em 2em; margin: 2em 0" ** Warning ** The following documentation corresponds to the [Proposals/Jinja Jinja] development proposal; it will be in Trac [milestone:1.3.2] if all goes well \\ (Git branch: [log:cboos.git@jinja2] (original) - [log:cboos.git@jinja2-trunk-r15379] (latest) - [https://github.com/cboos/trac.git github mirror]). Track the integration progress in #12639. }}} [[PageOutline(2-4)]] = Porting Templates from Genshi to Jinja2 The following documentation is primarily targeted at plugin developers who wish to adapt their Genshi templates to the Jinja2 template engine that will be used in Trac [milestone:1.4]. == Overview We start we some examples, showing both the legacy Genshi templates and the new Jinja2 templates, highlighting their main differences. The second part of the document describes the Python code changes, from what you need to change to trigger the use of the Jinja2 renderer instead of the legacy Genshi renderer which still kicks in if nothing changes, to the new ways of generating content. Finally we go to great length to explain the most difficult part of the migration, how to replace the deprecated `ITemplateStreamFilter` interface which has no direct equivalent with Jinja2. In the last part of this document, we try to cover all the Genshi features used by Trac and present their Jinja2 equivalent. Whenever possible, we tried to minimize these differences by customizing the Jinja2 syntax. For example, we use `${...}` for variable expansion, like Genshi does, instead of `{{...}}`. Another aspect of our usage convention is that we favor [#ifthenelse line statements] over `{% ... %}`. So even someone familiar with the "default" Jinja2 syntax should glance through this document to see how "we" use Jinja2, as summarized in the table below. Note that Genshi will be supported concurrently with Jinja2 only for a short while, for the 1.3.x development period and for the 1.4-stable period. This support will be removed in Trac [milestone:1.5.1]. If for some reason you're stuck to having to support Genshi templates, you'll have to stick to Trac 1.2.x or 1.3.1. But you really should make the transition effort as Jinja2 templates are 5-10x faster than their Genshi equivalent, for only a 1/5th of their cost in memory usage. == Examples! Before going into the details of the code changes involved and the precise differences in the template syntax between the two systems, let's see at a glance how the templates look like. === Standalone template Let's first take a simple full-contained example from the Trac source, the simple index.html / jindex.html templates. - Genshi [source:sandbox/genshi/templates/index.html@3728 index.html]: {{{#!html+genshi