2010-11-04

mustache

By playing with couchapp I run into a yet another templating language/tool: mustache
its a ruby tool and installing is easy as:


sudo gem install mustache


this the data represented as YAML (test.yml)

---
"names": [ {name: chris}, {"name": "mark"}, {name: scott} ]
---


A template can be a text file containing special tags marked with {{ and }}

{{#names}}
Hi {{name}}!
{{/names}}



> mustache test.yml templ.mustache

Hi chris!
Hi mark!
Hi scott!



for a detailed description about the mustache syntax see the docs

There is also a javascript api for it

Mustache.to_html(ddoc.templates.restaurant, {"rests":rests})

where the first parameter the template, and the second is the 'model'.

syntax highlighted code in html

There is a nice tool called Pygment

installation is easy as:

sudo easy_install Pygments


this is how you can generate


pygmentize -O full -o delme.html -f html markdown.js