LiquidJS is compatible to the express template engines. You can set liquidjs instance to the view engine option:
var { Liquid } = require('liquidjs'); |
Working DemoHere’s a working demo for LiquidJS usage in Express.js: liquidjs/demo/express/.
Template Lookup
The root option will continue to work as templates root, as you can see in Render A Template File. Additionally, the views
option in express.js (as shown above) will also be respected. Say you have a template directory like:
. |
And you’re setting template root for liquidjs to views1
and expressjs to views2
:
var { Liquid } = require('liquidjs'); |
Both of hello.liquid
and world.liquid
can be resolved and rendered:
res.render('hello') |
Caching
Simply setting the cache option to true will enable template caching, as explained in Caching. It’s recommended to enable cache in production environment, which can be done by:
var { Liquid } = require('liquidjs'); |