# [9.0.0](https://github.com/harttle/liquidjs/compare/v8.5.3...v9.0.0) (2019-08-26) ### Bug Fixes * break/continue omitting output before them, [#123](https://github.com/harttle/liquidjs/issues/123) ([ae45c46](https://github.com/harttle/liquidjs/commit/ae45c46)) * reactjs demo during yarn install, fixes [#145](https://github.com/harttle/liquidjs/issues/145) ([b65df44](https://github.com/harttle/liquidjs/commit/b65df44)) ### Code Refactoring * return value of Tag#render is no longer used ([8028f82](https://github.com/harttle/liquidjs/commit/8028f82)) ### Features * renderSync, parseAndRenderSync and renderFileSync, see [#48](https://github.com/harttle/liquidjs/issues/48) ([7fb01ad](https://github.com/harttle/liquidjs/commit/7fb01ad)) ### Performance Improvements * target to es6, fixes [#137](https://github.com/harttle/liquidjs/issues/137) ([3b9fc7e](https://github.com/harttle/liquidjs/commit/3b9fc7e)) ### BREAKING CHANGES * Tag#render now returns void, use emitter argument to write rendered html. * ship to Node.js 8, the dist/liquid.cjs.js (main) nolonger supports Node.js 6, other bundles are also provided via dist/liquid.esm.js, dist/liquid.js (ES5 umd) and liquid.min.js (minified ES5 umd) * remove default export, now should be used like import {Liquid} from 'liquidjs'
liquidjs
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. All features, filters and tags in shopify/liquid are supposed to be built in LiquidJS, though there are still some differences and limitations (see below).
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 (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
- A live demo is available on jsfiddle: https://jsfiddle.net/6u40xbzs/
- For more tutorials and the full API, refer to the wiki page.
- Typedoc is also available here: https://harttle.github.io/liquidjs/classes/_liquid_.liquid.html
Differences and Limitations
- Dynamic file locating (enabled by default), that means layout/partial names are treated as variables in liquidjs. See #51.
- Truthy and Falsy. All values except
undefined,null,falseare truthy, whereas in Ruby Liquid all exceptnilandfalseare truthy. See #26. - Number. In JavaScript we cannot distinguish or convert between
floatandinteger, see #59. And when appliedsizefilter, numbers always return 0, which is 8 for integer in ruby, cause they do not have alengthproperty. - .to_liquid() is replaced by
.toLiquid() - .to_s() is replaced by JavaScript
.toString()
Features that available on shopify website but not on shopify/liquid repo will not be implemented in this repo, but there're some plugins available (feel free to add yours):
- color filters: https://github.com/harttle/liquidjs-color-filters
- sections tags (WIP): https://github.com/harttle/liquidjs-section-tags
Contributors ✨
This project follows the all-contributors specification. Contributions of any kind are welcome! Thanks goes to these wonderful people:
