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.