Find file
Fetching contributors…
Cannot retrieve contributors at this time
79 lines (49 sloc) 1.49 KB


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.


The different Mustache tags are documented at mustache(5).

Install It

pip install pystache

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

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!

pip install nose
cd pystache


context = { 'author': 'Chris Wanstrath', 'email': '' }
pystache.render("{{author}} :: {{email}}", context)