liquid-lite

Liquid template engine for browser and node.js

Liquid template engine

Lite version of Liquid markup template engine writen in javascript. Download compressed (924 bytes or 594 bytes gzipped) or uncompressed source.

Full version in ruby is available by Shopify

<ul class="products">
  {% for product in products limit:5 %}
    <li>
      <h2>{{ product.title | upcase }}</h2>
      Only {{ product.price }}
      <p>{{ product.description }}</p>
    </li>
  {% endfor %}
 
  {% for product in products offset:5 %}
    <li>{{ product.title }} {{ product.price }}</li>
  {% endfor %}
</ul>

See test.html for more examples

Liquid Filters are available thru prototypes. Make as many as you need.

String.prototype.capitalize = function() {
    return this.charAt(0).toUpperCase() + this.slice(1)
}
String.prototype.upcase = String.prototype.toUpperCase
String.prototype.downcase = String.prototype.toLowerCase
String.prototype.size = function() {
    return this.length
}
Array.prototype.first = function() {
    return this[0]
}

Copyright (c) 2012 Lauri Rooden <lauri@rooden.ee>
The MIT License