Towards a shared implementation of Mustache, Handlebars, Liquid and Django Templates?

231 views
Skip to first unread message

Magnus Holm

unread,
Sep 10, 2010, 1:11:38 PM9/10/10
to guardians-o...@googlegroups.com, wyc...@gmail.com
Hey folks,

There's several context-stack-based template engines now: The main
idea with them is that instead of using Ruby, you write in a custom
markup language and there's an implied stack which changes the lookup:

Example from Mustache/Handlebars.js:

{{name}} <- Refers to a top-level name-attribute
{{#projects}}
# The stack is pushed with the projects data.
{{name}} <- Could refer to the name of a project, or a top-level
name-attribute
{{/projects}}
# The stack is popped
{{name}} <- Refers to the top-level name-attribute again

Liquid:

{% for a in b %}
# The stack is pushed with `a`
{{ a.name }}
{% endfor %}
# The stack is popped, `a` is no longer available

There's probably several places where all of these engines can share
code (maybe only have different parsers) and by doing this the
Temple-way they can all take advantage of different optimizations. For
instance, I've written Handlebars-JIT which speeds up Mustache with
2x, but the same idea can also be applied to all of these engines.

Supporting both Mustache and Handlebars.js (by wycats) would the first
goal, but as it's written we should build it in such a way that it's
simple to include support for Liquid and other context-stack-based
template engines.

Any thoughts?

// Magnus Holm

Timothy N. Tsvetkov

unread,
Oct 17, 2010, 5:26:43 AM10/17/10
to Guardians of the Temple
I forked Liquid and extended a bit. My fork now works in production
well for us but it is slow because Liquid is slow. Our response time
is ok for our customers, but I start working on boosting my fork of
Liquid. And now looking for libs for compiling it or maybe I should
write my own one? Have you tried Temple? What do you think about it?

Magnus Holm

unread,
Oct 18, 2010, 5:12:55 AM10/18/10
to guardians-o...@googlegroups.com
Hey Timothy,

I have started the work on a Liquid clone (called "Solid") which compiles to Temple and works pretty well. There are some minor differences in the syntax though, but they're mostly for the better. If you're interested I can try to clean it up and publish it.

As the author of Temple, I'll have to say that it's pretty awesome ;-)

// Magnus Holm
Reply all
Reply to author
Forward
0 new messages