egg view plugin for liquidJs
npm install egg-view-liquid[![NPM version][npm-image]][npm-url]

[npm-image]: https://img.shields.io/npm/v/egg-view-art.svg
[npm-url]: https://npmjs.org/package/egg-view-art
egg view plugin for [liquid].
``bash`
$ npm i egg-view-liquid --save
`js
// {app_root}/config/plugin.js
exports.liquid = {
enable: true,
package: 'egg-view-liquid',
};
// {app_root}/config/config.default.js
exports.view = {
mapping: {
'.liquid': 'liquid',
},
};
// liquid config
exports.liquid = {};
`
Create a liquid file
`js`
// app/view/hello.liquid
hello {{ data }}
Render it
`js`
// app/controller/render.js
exports.liquid = async ctx => {
await ctx.render('hello.liquid', {
data: 'world',
});
};
The file will be compiled and cached, you can change config.liquid.cache = false to disable cache, it's disable in local env by default.
You can include both relative and absolute file.
Relative file is resolve from current file path.
`html`
// app/view/a.liquid include app/view/b.liquid
{% render 'view/b' %}
Absolute file is resolve from app/view.
`html`
// app/view/home.liquid include app/view/partial/menu.liquid
{% render 'partial/menu' %}
1. Use when you need to import files: partial/xxx not /partial/xxx
2. LiquidJs currently does not support direct use of method calls in files: Hello {{helper.data()}} can be replaced with tags or plugins if needed.
3. Now, if you want to use LiquidJs for like express-ejs-Layout's contentfor, just use LiquidJs's block` instead.
see config/config.default.js for more detail.
Please open an issue here.
[liquid]: https://github.com/harttle/liquidjs