Skip to main content

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

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

Install It

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

easy_install nose
cd pystache
nosetests

Author

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

History

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

Metadata

Release files for pystache 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pystache 0.3.1
File Size Uploaded
pystache-0.3.1.tar.gz 4.5 kB Details

Release files / pystache-0.3.1.tar.gz

Download URL pystache-0.3.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c7e41c59c981a4c76a381aba4fe4f85d470836e5ea863b721f21231201f5af22
BLAKE2b-256 checksum
How to use checksums
235bc17c11a18fe7c1717e4d3644a0b21f2b76d70622c68a790403b211842c55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.6.8

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.0

1 release file

0.5.4

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

This release

0.3.1 This release

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page