Skip to main content

Trimmed mustache logic-less templates

Project description

Stache

Trimmed mustache logic-less templates

Implements everything from http://mustache.github.com/mustache.5.html except for partials and lambdas in ~150 lines of code(with tests).

Why?

Because the current https://github.com/defunkt/pystache implementation has holes. And because I wanted to learn about python generators. As a result my codebase is considerabley smaller and easier to grok too. Also benchmarking the two with my tests, mine was slightly faster, around 2x to 3x.

Install

pip install stache

Test

You can run python test.py or if you have nosetests:

cd stache nosetests

Benchmark:

python test.py

Usage:

>>> from Stache import Stache
>>> Stache().render("Hello {{who}}!", dict(who="World"))
Hello World

or

>>> import Stache
>>> Stache.render("Hello {{world}}!", dict(world="Stache!"))
Hello Stache!

Timeline

I’m planning to implement partials, but I’m wary of lambdas, because I want the templates to be language agnostic. The main reason I liked Mustache is because of template reuse.

Some future ideas I have is rendering to javascript templates to be used on browser frontend, bypassing the need for a client side script to compile it into javascript

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

Stache-0.0.2.zip (2.9 kB view hashes)

Uploaded Source

Stache-0.0.2.tar.gz (2.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page