Edgewall Software

Changes between Version 22 and Version 23 of TracDev/PortingFromGenshiToJinja


Ignore:
Timestamp:
Mar 26, 2016, 8:04:09 PM (8 years ago)
Author:
Christian Boos
Comment:

add section describing the #ChangesintheHTML

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/PortingFromGenshiToJinja

    v22 v23  
    1 {{{#!div class="important" style="padding: 0em 2em; margin: 2em 0"
     1{{{#!div class="important" style="text-align: center; padding: 0em 2em; margin: 2em 0"
    22** Warning **
    33
    4 The following documentation corresponds to an experimental branch ([[Proposals/Jinja]];  Git branch: [log:cboos.git@jinja2] - [https://github.com/cboos/trac.git github mirror]).
     4The following documentation corresponds to the [Proposals/Jinja Jinja] development proposal; it will be in Trac 1.3.x if all goes well \\
     5(Git branch: [log:cboos.git@jinja2] - [https://github.com/cboos/trac.git github mirror]).
    56}}}
    67
     
    1415Compare the 'j...' Jinja templates found in source:cboos.git/trac/templates@jinja2 with their corresponding Genshi ones.
    1516
    16 Note that Genshi will **not** be supported concurrently with Jinja2.
    17 If for some reason you're stuck to having to support Genshi templates, you'll have to stick to Trac 1.2.x. But you really should make the transition effort as Jinja2 templates are 5-10x faster than their Genshi equivalent, for a 1/5th of the cost in memory usage.
     17Note that Genshi will be supported concurrently with Jinja2 only for a short while, probably only during the 1.3.x development period.
     18If 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.x. 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 the cost in memory usage.
     19
     20
     21
     22== Changes in the HTML
     23
     24We took the opportunity to switch to HTML5 while performing this template overhaul.
     25You should probably do the same.
     26This usually won't change anything for your templates, except for a few details.
     27
     28The doctype and the <html> element should be changed from Genshi's:
     29{{{#!html+genshi
     30<!DOCTYPE html
     31    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     32    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     33<html xmlns="http://www.w3.org/1999/xhtml"
     34      xmlns:py="http://genshi.edgewall.org/"
     35      xmlns:i18n="http://genshi.edgewall.org/i18n"
     36      xmlns:xi="http://www.w3.org/2001/XInclude">
     37}}}
     38
     39to the somewhat simpler:
     40{{{#!xml
     41<!DOCTYPE html>
     42<html>
     43}}}
     44
     45Special care should be taken when dealing with //void elements//.
     46In XHTML, it's fine to write:
     47{{{#!xml
     48<div id="description"/>
     49}}}
     50However, when going to HTML5, you should use instead:
     51{{{#!xml
     52<div id="description"></div>
     53}}}
     54The valid [https://www.w3.org/TR/html-markup/syntax.html#void-elements void elements] in HTML5 are limited to the following list:
     55 - area, base, br, col, command, embed, hr, img, input, keygen, link, meta, param, source, track, wbr
    1856
    1957