About Archive Tag Cloud Translations RSS

You are writing a comment about Replacing Django's Template Language With Jinja2, here is a quick summary:

The first example in the Loosely Coupled Django series, this entry looks at replacing Django's template language with the freshly released Jinja2 template language.


You are responding to this comment written by Trevor Caira on March 13th 2009, 17:14.

It is no longer necessary to manually write and rewrite the Django / Jinja2 glue code for each django project you want to use Jinja templates.

Instead you can use chouwa, a library specifically designed for this purpose. For example, the above would become:

# jinjaglobals.py
from chouwa.decorators import jinjatest

@jinjatest
def greater_than_fifty(x):
    return x > 50

# views.py
from chouwa.shortcuts import direct_to_template

def index(request):
    n = int(math.floor(100 * random.random()))
    return direct_to_template(request, 'with_jinja/index.html', {'n': n})

For further details, see the chouwa documentation.


Please be aware that comment forms go stale after one hour.





Comments may make use of LifeFlow MarkDown. Raw html will be escaped.


Quick Introduction to LifeFlow MarkDown Syntax

A highlighted code block:

@@ ruby
def a (b, c):
  b * c
end
@@

Other common languages work as well: scheme, python, java, html, etc.

Other markdown syntax:

 ### This is an h3 title
#### This is an h4 title
**this is bold**
*this is italics*

1. This is an
2. ordered list

* And an unordered
* list too

[this is a link](http://www.lethain.com/ "Lethain")