Changes between Version 1 and Version 2 of TracDev/JinjaChecker
- Timestamp:
- Jul 21, 2016, 1:24:57 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/JinjaChecker
v1 v2 5 5 To help with that problem, we wrote the [source:cboos.git/contrib/jinjachecker.py contrib/jinjachecker.py] tool. 6 6 7 It first analyzes the Jinja2 control structures, and tries to provide some helpful diagnostics in case of nesting or stylistic errors. 8 It also adds curly braces to the statements, so if you have an editor which can do matching of brace pairs, you can quickly spot the origin o a nesting problem. 9 10 Finally, while the indentation of the statements is free in Jinja2 templates, being consistent with it also helps to ensure a proper nesting. 11 12 == Example 13 14 The command: 7 15 {{{ 8 16 python contrib/jinjachecker.py trac/wiki/templates/jwiki_view.html 9 17 }}} 10 18 11 It first analyzes the Jinja2 control structures, and tries to provide some helpful diagnostics in case of nesting or stylistic errors. 12 It also adds curly braces to the statements, so if you have an editor which can do matching of brace pairs, you can quickly spot the origin o a nesting problem. 13 14 Finally, while the indentation of the statements is free in Jinja2 templates, being consistent with it also helps to ensure a proper nesting. 19 outputs: 15 20 {{{ 16 21 # -- Jinja2 check for 'trac/wiki/templates/jwiki_view.html' … … 102 107 }}} 103 108 104 As a second step, jinjachecker removes the Jinja2 markup and performs a validation of the document, using lxml. 109 and: 105 110 {{{ 106 111 # -- HTML check for 'trac/wiki/templates/jwiki_view.html' … … 149 154 # -- HTML OK 150 155 }}} 156 157 The second part of this output is only generated if you have [pypi:lxml] installed. If that's the case, after having checked the Jinja2 syntax nesting in a first step, the jinjachecker tool removes the Jinja2 markup and performs a validation of the document using lxml in a second step.