feature: rendering options for express

This commit is contained in:
harttle
2016-09-27 13:07:04 +08:00
parent fe049b48e2
commit 1e1b6e8cc3
4 changed files with 14 additions and 8 deletions
+8 -3
View File
@@ -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
```
+2 -2
View File
@@ -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);
+3 -3
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -5,6 +5,7 @@
"main": "index.js",
"scripts": {
"test": "mocha --recursive",
"prepublish": "npm test && make dist",
"dist": "make dist"
},
"repository": {