documents for whitespace control (#17)

This commit is contained in:
harttle
2016-12-27 00:09:39 +08:00
parent d032f7f4d4
commit 5b5dfd5c00
2 changed files with 15 additions and 4 deletions
+12 -3
View File
@@ -52,9 +52,11 @@ engine.render(tpl, {name: 'alice'})
```javascript
var engine = Liquid({
root: path.resolve(__dirname, 'views/'), // for layouts and includes
extname: '.liquid',
cache: false,
root: path.resolve(__dirname, 'views/'), // for layouts and includes, default: ["."]
extname: '.liquid', // default: '.liquid'
cache: false, // default: false
trim_right: false, // default: false
trim_left: false, // default: false
strict_filters: false, // default: false
strict_variables: false // default: false
});
@@ -83,6 +85,12 @@ Defaults to `process.cwd()`
If set to `false`, undefined variables will be rendered as empty string.
Otherwise, undefined variables will cause an exception. Defaults to `false`.
* `trim_right` is used to strip whitespace (including whitespace, tabs, line feeds, etc. which is implemented by ECMA RegExp `\s`) from the right of tags (`{% %}`) and output markups (`{{ }}`).
* `trim_left` is the same with `trim_right`, whereas it trims from the left.
> `{%- -%}` or `{{- -}}` markups also works to trim whitespace, see [Whitespace Control][whitespace control].
## Use with Express.js
```javascript
@@ -217,3 +225,4 @@ engine.registerTag('upper', {
[any-promise]: https://github.com/kevinbeaty/any-promise
[test]: https://github.com/harttle/shopify-liquid/tree/master/test
[caniuse-promises]: http://caniuse.com/#feat=promises
[whitespace control]: https://github.com/harttle/shopify-liquid/wiki/Whitespace-Control
+3 -1
View File
@@ -120,7 +120,9 @@ function factory(options) {
cache: false,
extname: '.liquid',
trim_right: false,
trim_left: false
trim_left: false,
strict_filters: false,
strict_variables: false
}, options);
options.root = normalizeStringArray(options.root);