Changes between Version 28 and Version 29 of TracDev/Proposals/Jinja
- Timestamp:
- Jul 13, 2016, 12:53:17 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/Proposals/Jinja
v28 v29 3 3 = Switch to the Jinja2 Template Engine 4 4 5 We've decided some time ago to remove the legacy support for the ClearSilver template engine for Trac 1.0 (r10570). Clearsilver had its share of inconveniences, enough that we decided to switch to the nicer [http://genshi.edgewall.org/ Genshi template engine] in 0.11, but ClearSilver was **very** fast and memory lenient. While we managed to keep Genshi memory usage somewhat in control (#6614), the speed was never really adequate, especially for big changesets and for displaying source files over a few thousand lines of code (see TracDev/Performance#Genshi for details). 5 == Background 6 6 7 So one solution would be to switch template engine once again, to one that would combine the advantages of Genshi (pure Python, nice templates, flexible) and ClearSilver (speed!). Such a beast seems to exist now: **[http://jinja.pocoo.org/2/documentation/ Jinja2]**. 7 **[http://jinja.pocoo.org/2/documentation/ Jinja2]** is a [wikipedia:Web_template_system template engine] that combines the advantages of Genshi (pure Python, nice templates, flexible) and ClearSilver (speed!). 8 9 We've decided some time ago to remove the legacy support for the ClearSilver template engine for Trac 1.0 (r10570), because of its many inconveniences, and to switch to the nicer [http://genshi.edgewall.org/ Genshi template engine] in Trac 0.11. While we managed to keep Genshi memory usage somewhat in control (#6614), the speed was never really adequate, especially for big changesets and for displaying source files over a few thousand lines of code (see TracDev/Performance#Genshi for details). Hence the proposal to look into an alternative template engine. 10 11 The Jinja2 template engine has the peripheral benefit of being used by the Django community: [gdiscussion:trac-dev/KqWPQWuZ63k/GPfda0_PDgAJ]. 8 12 9 13 == Overview of activities and progress 10 14 11 There 's an experimental branch which supports this proposal: [source:cboos.git@jinja2] \\12 (mirror available in [https://github.com/cboos/trac.git github] - 13 [[Image(https://travis-ci.org/cboos/trac.svg?branch=jinja2,link=https://travis-ci.org/cboos/trac,valign=bottom)]] on Travis,14 [[Image(https://ci.appveyor.com/api/projects/status/kqgv4awct01hsl7t/branch/jinja2?svg=true,link=https://ci.appveyor.com/project/cboos/trac/branch/jinja2,valign=bottom)]] on AppVeyor )15 There is an experimental branch which supports this proposal: [source:cboos.git@jinja2]. A mirror is available in [https://github.com/cboos/trac.git github]. 16 17 Automatic builds: [[Image(https://travis-ci.org/cboos/trac.svg?branch=jinja2,link=https://travis-ci.org/cboos/trac,valign=bottom)]] on Travis, 18 [[Image(https://ci.appveyor.com/api/projects/status/kqgv4awct01hsl7t/branch/jinja2?svg=true,link=https://ci.appveyor.com/project/cboos/trac/branch/jinja2,valign=bottom)]] on AppVeyor. 15 19 16 20 [=#Status Status] of the branch (2016-03-20): 17 - ported **77.8%** of the Genshi templates, the automated tests should stay sgreen21 - ported **77.8%** of the Genshi templates, the automated tests should stay green 18 22 - detailed porting guide: **PortingFromGenshiToJinja** 23 - TODO accesskey support 19 24 - DONE clarify upgrade path for plugins that came to rely on `ITemplateStreamFilter`s? 127/898 plugins (14.1%) on trac-hacks.org use `filter_stream()` -> see [PortingFromGenshiToJinja#ReplacingITemplateStreamFilter replacing ITemplateStreamFilter] 20 25 * DONE clarify how to handle themeing? -> see HtmlTemplates#Jinjaarchitecture 21 26 * DONE rewrite tag builders ~~or use lightweight string templates~~? -> [PortingFromGenshiToJinja#tag tag] `Fragment`/`Element` builder API has been reimplemented 22 - TODO accesskey support23 27 - DONE hack `ITemplateStreamFilter` support for Jinja2 templates 24 28 - DONE site.html replacement, for example try to reproduce t.e.o customizations -> [./TracInterfaceCustomization] … … 29 33 30 34 The topic is now (Feb / March 2016) again discussed on [gdiscussion:trac-dev:KqWPQWuZ63k trac-dev]. 31 32 The Jinja2 template engine has the peripheral benefit of being used by the Django community: [gdiscussion:trac-dev/KqWPQWuZ63k/GPfda0_PDgAJ].33 35 34 36 == Experimenting with Jinja2 (2.8)