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 works on–
Python 2.4
Python 2.5
Python 2.6
Python 2.7
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
Depending on your Python version and nose installation, you may need to type, for example
nosetests-2.4
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.
History
0.4.1 (2012-03-25)
Added support for Python 2.4. [wangtz, jvantuyl]
0.4.0 (2011-01-12)
Add support for nested contexts (within template and view)
Add support for inverted lists
Decoupled template loading
0.3.1 (2010-05-07)
Fix package
0.3.0 (2010-05-03)
View.template_path can now hold a list of path
Add {{& blah}} as an alias for {{{ blah }}}
Higher Order Sections
Inverted sections
0.2.0 (2010-02-15)
Bugfix: Methods returning False or None are not rendered
Bugfix: Don’t render an empty string when a tag’s value is 0. [enaeseth]
Add support for using non-callables as View attributes. [joshthecoder]
Allow using View instances as attributes. [joshthecoder]
Support for Unicode and non-ASCII-encoded bytestring output. [enaeseth]
Template file encoding awareness. [enaeseth]
0.1.1 (2009-11-13)
Ensure we’re dealing with strings, always
Tests can be run by executing the test file directly
0.1.0 (2009-11-12)
First release
Release files for pystache 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pystache-0.4.1.tar.gz | 6.6 kB | Details |
Release files / pystache-0.4.1.tar.gz
| Download URL | pystache-0.4.1.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4821650a18f31be79e181fd1faba403e55e25804c5b9aac470bb2f0c57f34c30
|
|
BLAKE2b-256 checksum How to use checksums |
00745be8897444d0cc3214dd6de6acf11e46e4d420c3693df55f401b068a4bdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |