mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-19 22:40:48 -07:00
documents for whitespace control (#17)
This commit is contained in:
@@ -52,9 +52,11 @@ engine.render(tpl, {name: 'alice'})
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var engine = Liquid({
|
var engine = Liquid({
|
||||||
root: path.resolve(__dirname, 'views/'), // for layouts and includes
|
root: path.resolve(__dirname, 'views/'), // for layouts and includes, default: ["."]
|
||||||
extname: '.liquid',
|
extname: '.liquid', // default: '.liquid'
|
||||||
cache: false,
|
cache: false, // default: false
|
||||||
|
trim_right: false, // default: false
|
||||||
|
trim_left: false, // default: false
|
||||||
strict_filters: false, // default: false
|
strict_filters: false, // default: false
|
||||||
strict_variables: 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.
|
If set to `false`, undefined variables will be rendered as empty string.
|
||||||
Otherwise, undefined variables will cause an exception. Defaults to `false`.
|
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
|
## Use with Express.js
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
@@ -217,3 +225,4 @@ engine.registerTag('upper', {
|
|||||||
[any-promise]: https://github.com/kevinbeaty/any-promise
|
[any-promise]: https://github.com/kevinbeaty/any-promise
|
||||||
[test]: https://github.com/harttle/shopify-liquid/tree/master/test
|
[test]: https://github.com/harttle/shopify-liquid/tree/master/test
|
||||||
[caniuse-promises]: http://caniuse.com/#feat=promises
|
[caniuse-promises]: http://caniuse.com/#feat=promises
|
||||||
|
[whitespace control]: https://github.com/harttle/shopify-liquid/wiki/Whitespace-Control
|
||||||
|
|||||||
@@ -120,7 +120,9 @@ function factory(options) {
|
|||||||
cache: false,
|
cache: false,
|
||||||
extname: '.liquid',
|
extname: '.liquid',
|
||||||
trim_right: false,
|
trim_right: false,
|
||||||
trim_left: false
|
trim_left: false,
|
||||||
|
strict_filters: false,
|
||||||
|
strict_variables: false
|
||||||
}, options);
|
}, options);
|
||||||
options.root = normalizeStringArray(options.root);
|
options.root = normalizeStringArray(options.root);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user