Edgewall Software

Changes between Version 15 and Version 16 of TracDev/Proposals/Jinja


Ignore:
Timestamp:
Feb 23, 2016, 9:03:55 PM (8 years ago)
Author:
Christian Boos
Comment:

add the example of the admin panels

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/Proposals/Jinja

    v15 v16  
    1010 * what will be the upgrade path for plugins that came to rely on `ITemplateStreamFilter`s?
    1111   - 127/898 plugins (14.1%) on trac-hacks.org use `filter_stream()`
    12    - see [PortingFromGenshiToJinja#ReplacingITemplateStreamFilter replacing ITemplateStreamFilter]
    13  * how to handle themeing? see [#Themeing] below
    14  * should we rewrite tag builders or use lightweight string templates? -> [PortingFromGenshiToJinja#tag tag] `Fragment`/`Element` builder has been replaced, and is backward compatible
     12   - -> [PortingFromGenshiToJinja#ReplacingITemplateStreamFilter replacing ITemplateStreamFilter]
     13 * how to handle themeing? -> see [#Themeing] below
     14 * should we rewrite tag builders or use lightweight string templates? -> [PortingFromGenshiToJinja#tag tag] `Fragment`/`Element` builder has been reimplemented
    1515 * others?
    1616
     
    375375parent template it wants or not ("bottom-up" control), something that was not
    376376readily doable with Genshi ("top-down" control).
     377
     378
     379Like what we did with Genshi, this scheme can be extended to support additional intermediate levels. We did that for the admin and the preference panels.
     380
     381Let's take for example the Logging admin panel, [source:cboos.git/trac/admin/templates/jadmin_logging.html jadmin_logging.html]:
     382{{{#!html+jinja
     383# extends "jadmin.html"
     384<html>
     385  <head>
     386    <title>
     387      # block admintitle
     388      Logging
     389      # endblock admintitle
     390    </title>
     391  </head>
     392
     393  <body>
     394    # block adminpanel
     395    ...
     396    # block adminpanel
     397  </body>
     398</html>
     399}}}
     400 - it starts by extending the jadmin.html page
     401 - then it provides the `<head>` and `<body>` elements specific to that panel,
     402   more precisely the //admintitle// and //adminpanel// blocks (if some JavaScript
     403   or other resources are needed, the //head// could be redefined as well)
     404   
     405The [source:cboos.git/trac/admin/templates/jadmin.html@jinja2 jadmin.html] page
     406is similar to the jsearch.html page in that it extends the jlayout.html:
     407{{{#!html+jinja
     408# extends "jlayout.html"
     409<html>
     410  <head>
     411    <title>
     412      # block title
     413      Administration:
     414      #   block admintitle
     415      #   endblock admintitle
     416      ${ super() }
     417      # endblock
     418    </title>
     419  </head>
     420
     421  <body>
     422    # block content
     423    <div id="content" class="admin">
     424      <h1>Administration</h1>
     425      <div id="tabs">
     426      <div id="tabcontent">
     427        # block adminpanel
     428        # endblock adminpanel
     429        <br style="clear: right" />
     430      </div>
     431    </div>
     432    # endblock content
     433  </body>
     434</html>
     435}}}
     436
     437//See [1df4e05c/cboos.git] for the full conversion of admin.html -> jadmin.html and admin_logging.html -> jadmin_logging.html.//
     438
    377439
    378440I omitted the discussion of the