10
Home
Brandon Pittman edited this page 2019-11-11 22:37:53 +09:00

Welcome to the liquidjs wiki! Liquidjs is a shopify compatible Liquid template engine in pure JavaScript. The purpose of this repo is to provide a standard Liquid implementation for the JavaScript community.

Get Started

Install via npm:

npm install --save liquidjs
var { Liquid } = require('liquidjs');
var engine = new Liquid();

engine
    .parseAndRender('{{name | capitalize}}', {name: 'alice'})
    .then(console.log);     // outputs 'Alice'

Or include the UMD build, a live demo is available on jsfiddle: https://jsfiddle.net/x43eb0z6/. You may need a Promise polyfill for Node.js < 4 and ES5 browsers like IE and Android UC.

<script src="//unpkg.com/liquidjs/dist/liquid.min.js"></script>     <!--for production-->
<script src="//unpkg.com/liquidjs/dist/liquid.js"></script>         <!--for development-->

Also available from CLI:

echo '{{"hello" | capitalize}}' | npx liquidjs

If you pass a path to a JSON file or a JSON string as the first argument, it will be used as the context for your template.

echo 'Hello, {{ name }}.' | npx liquidjs '{"name": "Snake"}'

More Demos

There's a live demo on JSFiddle, and a list of demo projects in the demo/ directory

Documentation

The tutorial contains a list of articles for advanced use cases, performance optimization and extending liquidjs.

The API Reference provides detailed descriptions for classes, methods and properties.