mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 21:40:39 -07:00
feature: rendering options for express
This commit is contained in:
@@ -74,14 +74,19 @@ engine.parseAndRender("{{ foo }}", {}, opts).catch(function(err){
|
||||
engine.parseAndRender("{{ 'foo' | filter1 }}", {}, opts).catch(function(err){
|
||||
// err.message === undefined filter: filter1
|
||||
});
|
||||
// Note:
|
||||
// `engine.render(tpl, ctx, opts)` and `engine.renderFile(path, ctx, opts)` also works.
|
||||
// Note: the below opts also work:
|
||||
// engine.render(tpl, ctx, opts)
|
||||
// engine.renderFile(path, ctx, opts)
|
||||
```
|
||||
|
||||
## Use with Express.js
|
||||
|
||||
```javascript
|
||||
app.engine('liquid', engine.express()); // register liquid engine
|
||||
// register liquid engine
|
||||
app.engine('liquid', engine.express({
|
||||
strict_variables: true, // Default: fasle
|
||||
strict_filters: true // Default: false
|
||||
}));
|
||||
app.set('views', './views'); // specify the views directory
|
||||
app.set('view engine', 'liquid'); // set to default
|
||||
```
|
||||
|
||||
Vendored
+2
-2
@@ -289,11 +289,11 @@ var _engine = {
|
||||
});
|
||||
});
|
||||
},
|
||||
express: function express() {
|
||||
express: function express(renderingOptions) {
|
||||
var _this3 = this;
|
||||
|
||||
return function (filePath, options, callback) {
|
||||
_this3.renderFile(filePath, options).then(function (html) {
|
||||
_this3.renderFile(filePath, options, renderingOptions).then(function (html) {
|
||||
return callback(null, html);
|
||||
}).catch(function (e) {
|
||||
return callback(e);
|
||||
|
||||
Vendored
+3
-3
File diff suppressed because one or more lines are too long
@@ -5,6 +5,7 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha --recursive",
|
||||
"prepublish": "npm test && make dist",
|
||||
"dist": "make dist"
|
||||
},
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user