This repository has been archived by the owner on Mar 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
R. Tyler Ballance
committed
Dec 26, 2009
1 parent
410371e
commit eb5f2fa
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Django/Cheetah Example | ||
========================= | ||
|
||
This is a simple project and application demonstrating | ||
using Cheetah (with dynamically compiled templates) for | ||
building views inside of [Django](http://www.djangoproject.com/) | ||
applications. | ||
|
||
Requires | ||
---------- | ||
* [Django](http://www.djangoproject.com/) | ||
* [Cheetah](http://cheetahtemplate.org) (>= v2.2.1) | ||
|
||
Getting Started | ||
----------------- | ||
For all intents and purposes, using Cheetah in place of Django's | ||
templating system is a trivial change in how you write your *views*. | ||
|
||
After following the Django [getting started](http://docs.djangoproject.com/en/1.1/intro/tutorial01/) | ||
documentation, you'll want to create a directory for your Cheetah templates, such | ||
as `Cheetar/templates`. Be sure to `touch __init__.py` in your template | ||
directory to ensure that templates can be imported if they need to. | ||
|
||
Add your new template directory to the `TEMPLATE_DIRS` attribute | ||
in your project's `settings.py`. | ||
|
||
Once that is all set up, utilizing Cheetah templates in Django is just | ||
a matter of a few lines in your view code: | ||
|
||
import Cheetah.Django | ||
|
||
def index(req): | ||
return Cheetah.Django.render('index.tmpl', greet=False) | ||
|
||
**Note**: Any keyword-arguments you pass into the `Cheetah.Django.render()` | ||
function will be exposed in the template's "searchList", meaning you can | ||
then access them with $-placeholders. (i.e. `$greet`) |