mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 05:50:43 -07:00
docs: better document for usage in browser, closes #165
+11
-1
@@ -42,10 +42,20 @@ It can be a string-typed path (see above example), or a list of root directories
|
||||
```javascript
|
||||
var engine = new Liquid({
|
||||
// relative paths will be resolved against `pwd`
|
||||
root: ['views/', 'views/partials/']
|
||||
root: ['views/', 'views/partials/'],
|
||||
extname: '.liquid'
|
||||
});
|
||||
```
|
||||
|
||||
When `{% render "foo" %}` is renderd or `liquid.renderFile('foo')` is called, the following files will be looked up and the first existing file will be used (if none of them exists an `ENOENT` error will be throwed):
|
||||
|
||||
- `pwd`/views/foo.liquid
|
||||
- `pwd`/views/partials/foo.liquid
|
||||
|
||||
When LiquidJS is used in browser, say current location is `https://harttle.com/bar/index.html`, only the first `root` will be used and the file to be fetched is (if fetch fails an `ENOENT` error will be throwed):
|
||||
|
||||
- `https://harttle.com/bar/foo.liquid`
|
||||
|
||||
## Abstract File System
|
||||
|
||||
LiquidJS defines an abstract file system interface in [src/fs/ifs.ts][ifs] and the default implementation is [src/fs/node.ts][fs-node] for Node.js and [src/fs/browser.ts][fs-browser] for the browser bundle.
|
||||
|
||||
Reference in New Issue
Block a user