Edgewall Software

Changes between Version 18 and Version 19 of TracDev/PortingFromGenshiToJinja


Ignore:
Timestamp:
Mar 17, 2016, 5:27:32 PM (8 years ago)
Author:
Christian Boos
Comment:

a bit of clean-up in #Standalonetemplate section

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/PortingFromGenshiToJinja

    v18 v19  
    389389
    390390Note that a Jinja2 .html template can usually be rendered directly in the browser, to have a rough taste of how it will look like:
    391 {{{#!div style="border: 1px solid #999; margin: 1em"
     391{{{#!div style="border: 2px solid #ccc; margin: 1em; padding: 0 2em"
    392392{{{#!html  (html mode on purpose here!)
    393393    <h1>${_("Available Projects")}</h1>
     
    407407}}}
    408408}}}
    409 Though there's no absolutely no constraints on a Jinja2 template, it helps to have an .xml or .html template be  itself '''a well-formed XML document'''.
    410 
    411 **Never** go back to the bad old Clearsilver habits were sometimes the logic in those templates took advantage of the lack of well-formedness constraints, e.g. by conditionally inserting end/start pairs of tags. Such templates were hard to maintain, and you always have cleaner alternatives.
    412 
    413 The [Proposals/Jinja#jinjachecker jinjachecker] tool should also help you maintain well-formed templates.
     409Though there's absolutely no constraints on what text a Jinja2 template may contain, for templates that will produce HTML (or XML), it will be useful if the template is itself already '''a well-formed XML document'''.
     410
     411**Never** go back to the bad old habits from the ClearSilver time, were sometimes the logic in those templates took advantage of the lack of well-formedness constraints, e.g. by conditionally inserting end/start pairs of tags to split sequences. Such templates were hard to maintain, and you always have cleaner alternatives.
     412
     413The [Proposals/Jinja#jinjachecker jinjachecker] tool should also help you maintain well-formed templates by stripping off Jinja2 expressions and line statements before attempting to XML validate the document ([pypi:lxml] should be installed for this feature).
    414414
    415415