Skip to content
Myr

[svn] again some updates on the documentation for jinja. this time the debugging stuff

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 2cc3c69 · Browse files · 3 files+76 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+76 added−4 removed

  • other:+76 added−4 removed

3 files+76 added−4 removed

added:docs/src/debugging.txt+27 added
1===================2Debugging Templates3===================45In order to keep templates debuggable you have to do some additional work on6the application side. The traceback module that comes with python currently7does not support the `__loader__` hook which is used by Jinja to provide8templates. Although the import system was implemented three Python versions9ago the default traceback system still doesn't support it.1011However most of the extended web development traceback module support it:1213- `Colubrid Debugging Middleware`_14- `cgitb`_15- `EvalException`_1617Note that the django traceback module currently does not provide this. `A18ticket`_ was filed already so there is hope that this will be fixed.1920To enable debugging you have to use one of those debugging systems or21implement your own one with support for `__loader__`.222324.. _Colubrid Debugging Middleware: http://trac.pocoo.org/repos/colubrid/trunk/colubrid/debug.py25.. _cgitb: http://docs.python.org/lib/module-cgitb.html26.. _EvalException: http://pythonpaste.org/module-paste.evalexception.html27.. _A ticket: http://code.djangoproject.com/ticket/3734
modified:docs/src/designerdoc.txt+47 added
281 unmodified lines
282 using an infix notation too: ``foo is not bar`` and ``foo not in bar``283 instead of ``not foo is bar`` and ``not foo in bar``. All other expressions284 require a prefix notation: ``not (foo and bar)``.285286Boolean Values287==============288289In If-Conditions Jinja performs a boolean check. All empty values (eg: empty290lists ``[]``, empty dicts ``{}`` etc) evaluate to `false`. Numbers that are291equal to `0`/`0.00` are considered `false` too. The boolean value of other292objects depends on the behavior the application developer gave it. Usually293items are `true`.294295Here some examples that should explain it:296297.. sourcecode:: jinja298299 {% if [] %}300 will always be false because it's an empty list301302 {% if {} %}303 false too.304305 {% if ['foo'] %}306 this is true. Because the list is not empty.307308 {% if "foobar" %}309 this is also true because the string is not empty.310311Slicing312=======313314Some objects support slicing operations. For example lists:315316.. sourcecode:: jinja317318 {% for item in items[:5] %}319 This will only iterate over the first 5 items of the list320321 {% for item in items[5:10] %}322 This will only iterate from item 5 to 10.323324 {% for item in items[:10:2] %}325 This will only yield items from start to ten and only returing326 even items.327328For more informations about slicing have a look at the `slicing chapter`_329in the "Dive into Python" e-book.330331Macros332======333334If you want to use a partial template in more than one place, you might want to
301 unmodified lines
636 {{ count }} users found.637 {% else %}638 one user found.639 {% endif %}640641.. _slicing chapter: http://diveintopython.org/native_data_types/lists.html#odbchelper.list.slice
modified:docs/src/index.txt+2 added-4 removed
22 unmodified lines
23 - `Translators <translators.txt>`_2425 - `Framework Integration <frameworks.txt>`_2627 - `Debugging Support <debugging.txt>`_2829- Template Designer Documentation:3031 - `Syntax Reference <designerdoc.txt>`_32
12 unmodified lines
4546- Jinja in TurboGears / django?4748- Changelog / Authors4748- Boolean Rules (empty lists evaluate to False etc)4950- Slicing