mirror of
https://github.com/harttle/liquidjs.git
synced 2026-10-03 09:05:14 -07:00
update README and unit test
This commit is contained in:
@@ -52,13 +52,8 @@ engine.render(tpl, {name: 'alice'})
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var engine = Liquid({
|
var engine = Liquid({
|
||||||
root: path.resolve(__dirname, 'views/'), // for layouts and includes, default: ["."]
|
root: path.resolve(__dirname, 'views/'), // dirs to lookup layouts/includes
|
||||||
extname: '.liquid', // default: '.liquid'
|
extname: '.liquid' // the default extname used for layouts/includes
|
||||||
cache: false, // default: false
|
|
||||||
trim_right: false, // default: false
|
|
||||||
trim_left: false, // default: false
|
|
||||||
strict_filters: false, // default: false
|
|
||||||
strict_variables: false // default: false
|
|
||||||
});
|
});
|
||||||
engine.renderFile("hello.liquid", {name: 'alice'})
|
engine.renderFile("hello.liquid", {name: 'alice'})
|
||||||
.then(function(html){
|
.then(function(html){
|
||||||
@@ -71,11 +66,15 @@ engine.renderFile("hello", {name: 'alice'})
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
The full list of options for `Liquid()` is listed as following:
|
||||||
|
|
||||||
* `root` is a directory or an array of directories to resolve layouts and includes, as well as the filename passed in when calling `.renderFile()`.
|
* `root` is a directory or an array of directories to resolve layouts and includes, as well as the filename passed in when calling `.renderFile()`.
|
||||||
If an array, the files are looked up in the order they occur in the array.
|
If an array, the files are looked up in the order they occur in the array.
|
||||||
Defaults to `process.cwd()`
|
Defaults to `["."]`
|
||||||
|
|
||||||
* `extname` is used to lookup the template file when filepath doesn't include an extension name. Defaults to `.liquid`
|
* `extname` is used to lookup the template file when filepath doesn't include an extension name. Defaults to `".liquid"`
|
||||||
|
|
||||||
* `cache` indicates whether or not to cache resolved templates. Defaults to `false`.
|
* `cache` indicates whether or not to cache resolved templates. Defaults to `false`.
|
||||||
|
|
||||||
@@ -85,11 +84,11 @@ 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_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 (`{{ }}`). Defaults to `false`.
|
||||||
|
|
||||||
* `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].
|
* `trim_left` is the same with `trim_right`, whereas it trims from the left. Defaults to `false`. See [Whitespace Control][whitespace control] for details.
|
||||||
|
|
||||||
|
|
||||||
## Use with Express.js
|
## Use with Express.js
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -365,7 +365,7 @@ describe('error', function() {
|
|||||||
.be.rejected
|
.be.rejected
|
||||||
.then(function(err) {
|
.then(function(err) {
|
||||||
expect(err.stack).to.contain('AssertionError: tag -a not found');
|
expect(err.stack).to.contain('AssertionError: tag -a not found');
|
||||||
expect(err.stack).to.match(/at .*:\d+:\d+\)$/);
|
expect(err.stack).to.match(/at .*:\d+:\d+\)/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user