Liquid with Node.js
This is a port of the original Liquid template engine from Ruby to Node.js. It uses Promises to support non-blocking/asynchronous variables, filters, and blocks.
Features
- Supports asynchronous variables, tags, functions and filters (helpers)
- Supports whitespace control
- Allows custom tags and filters to be added
- Supports full liquid syntax
- Based on original Ruby code
- High test coverage
What does it look like?
{% for product in products %} {{ product.name }} Only {{ product.price | price }} {{ product.description | prettyprint | paragraph }} {% endfor %}
Installation
npm install liquid
Usage
Liquid supports a very simple API based around the Liquid.Engine class. For standard use you can just pass it the content of a file and call render with an object.
const Liquid = const engine = engine // or engine
Usage with Connect and Express
app
Registering new filters
engine
Registering new tags
Take a look at the existing tags to see how to implement them.
Tag { return 'hello world' } engine
Tests
npm test
Similar libraries
- harttle/liquidjs (
liquidjs
on npm) is another actively maintained Liquid parser and render for Node.js - darthapo's Liquid.js is liquid ported to JavaScript to be run within the browser. It doesn't handle asynchrony.
- tchype's Liquid.js is
liquid-node
wrapped to run in a browser.
License
Contributors ✨
Thanks goes to these wonderful people (emoji key):
Marcel Jackwerth 💻 📖 |
Tony C. Heupel 💻 |
Chen Yangjian 💻 |
Henri Bergius 💻 |
Sam Tiffin 💻 |
Kris Ciccarello 💻 |
Cory Reed 💻 💡 📖 |
Sebastian Seilund 💻 |
Rob Loach 💻 |
Sarah Schneider 💻 |
Zeke Sikelianos 💻 📖 🚧 |
This project follows the all-contributors specification. Contributions of any kind welcome!