Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Mustache in Python
Python
Branch: master

This branch is 4 commits ahead, 1004 commits behind defunkt:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
pystache
tests
.gitignore
HISTORY.md
LICENSE
README.md
TODO
setup.py

README.md

Pystache

Inspired by ctemplate and et, Mustache is a framework-agnostic way to render logic-free views.

As ctemplates says, "It emphasizes separating logic from presentation: it is impossible to embed application logic in this template language."

Pystache is a Python implementation of Mustache. It has been tested with Python 2.6.1.

Documentation

For now check out the ctemplate or Mustache docs.

Use It

>>> import pystache
>>> pystache.render('Hi {{person}}!', {'person': 'Mom'})
'Hi Mom!'

You can also create dedicated view classes to hold your view logic.

Here's your simple.py: import pystache class Simple(pystache.View): def thing(self): return "pizza"

Then your template, simple.mustache: Hi {{thing}}!

Pull it together: >>> Simple().render() 'Hi pizza!'

Test It

nose works great!

easy_install nose
cd pystache
nosetests

Author

context = { 'author': 'Chris Wanstrath', 'email': 'chris@ozmm.org' }
pystache.render("{{author}} :: {{email}}", context)
Something went wrong with that request. Please try again.