Changes between Version 3 and Version 4 of TracDev/JinjaChecker
- Timestamp:
- Jul 27, 2016, 9:47:08 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/JinjaChecker
v3 v4 1 = `jinjachecker`1 = Jinjachecker 2 2 3 Jinja2 is very helpful when it detects any kind of error, as you always end up with a meaningful backtrace. Nevertheless, it can be tedious to get the nesting of control structures right. 4 5 To help with that problem, we wrote the [source:cboos.git/contrib/jinjachecker.py contrib/jinjachecker.py] tool. 3 Jinja2 is very helpful when it detects any kind of error, as you always end up with a meaningful backtrace. Nevertheless, it can be tedious to get the nesting of control structures right. To help with that problem, we wrote the [source:cboos.git/contrib/jinjachecker.py contrib/jinjachecker.py] tool. 6 4 7 5 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.6 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 of a nesting problem. 9 7 10 8 Finally, while the indentation of the statements is free in Jinja2 templates, being consistent with it also helps to ensure a proper nesting. … … 13 11 14 12 The command: 15 {{{ 13 {{{#!sh 16 14 python contrib/jinjachecker.py trac/wiki/templates/jwiki_view.html 17 15 }}} … … 158 156 159 157 == Known Issues 158 160 159 The tool won't yet detect nesting mistakes when the Jinja2 control structure nesting and the HTML element nesting are both independently correct (e.g. errors like the one fixed in [68094c2ea/cboos.git]). //This might be fixed in a 3rd pass, doing XML validation after having replaced the Jinja2 start/end keywords with "equivalent" XML elements.//