In case you’re not familiar with Liquid Template Language, see Introduction to Liquid Template Language.
LiquidJS in Node.js
Install via npm:
npm install --save liquidjs |
var { Liquid } = require('liquidjs'); |
Working DemoType definitions for LiquidJS are also exported and published, which makes it more enjoyable for TypeScript projects:Here’s a working demo for LiquidJS usage in Node.js: liquidjs/demo/nodejs/.
import { Liquid } from 'liquidjs'; |
Working DemoHere’s a working demo for LiquidJS usage in TypeScript: liquidjs/demo/typescript/.
LiquidJS in Browsers
Pre-built UMD bundles are also available:
<!--for production--> |
Working DemoHere’s a living demo on jsFiddle: jsfiddle.net/pd4jhzLs/1/, and the source code is also available in liquidjs/demo/browser/.
CompatibilityYou may need a Promise polyfill for legacy browsers like IE and Android UC, see caniuse statistics.
LiquidJS in CLI
LiquidJS is 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"}' |
Miscellaneous
A ReactJS demo is also added by @stevenanthonyrevo, see liquidjs/demo/reactjs/.