My favorites | Sign in
Project Logo
                
Code license: New BSD License
Labels: django, python, cheetah, template
Feeds:

Cheetah template engine for Django

Usage

  1. Use the render_cheetah_response shortcut just as you would use render_to_response
  2. Use the CheetahTemplate class to render contexts in your views from text or file

News - Now released a version which is the stand alone module django_cheetahtemplates and contains the application of the example below. See the source svn repository for the most up to date code.

Example

Put this in your views

from django_cheetahtemplates import render_cheetah_response,CheetahTemplate
from django.template import Context
from django.http import HttpResponse

def hello(request):
    # Use shortcut
    return render_cheetah_response('hello.tmpl', {'myvar':'hello world','range':range} )

def hello2(request):
    # Create and render context
    context = Context({'myvar':'hello'})
    context['range'] = range
    template = CheetahTemplate(filename='hello.tmpl')
    return HttpResponse(template.render(context))

Then create hello.tmpl somewhere in your TEMPLATE_DIRS

$myvar
#for i in $range(10)
$i#slurp
#end for

When you go to the url linked to either hello or hello2 you will see this

hello world 0123456789

Capabilities:

TODO:









Hosted by Google Code