Skip to content

Mustache in Python

License

Notifications You must be signed in to change notification settings

wangtzINT/pystache

Repository files navigation

Pystache

https://s3.amazonaws.com/webdev_bucket/pystache.png

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. Pystache requires Python 2.4.

Pystache is semantically versioned: http://semver.org.

Logo: David Phillips - http://davidphillips.us/

Documentation

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 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!

pip install nose cd pystache nosetests 

Mailing List

As of Nov 26, 2011, there's a mailing list, pystache@librelist.com.

Archive: http://librelist.com/browser/pystache/

Note: There's a bit of a delay in seeing the latest emails appear in the archive.

Author

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

About

Mustache in Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python100.0%