From 05058e022da0c946c2e2bd47219fee5fe8506e5c Mon Sep 17 00:00:00 2001 From: harttle Date: Mon, 14 Oct 2019 14:56:34 +0800 Subject: [PATCH] docs: fix links --- Home.md | 9 +++++---- Operators.md | 19 +++++++++++++++++-- Plugins.md | 11 +++++++---- Render-a-File.md | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 10 deletions(-) diff --git a/Home.md b/Home.md index 0923b1d..ae8ab02 100644 --- a/Home.md +++ b/Home.md @@ -35,7 +35,7 @@ echo '{{"hello" | capitalize}}' | npx liquidjs There's [a live demo][jsfiddle] on JSFiddle, and a list of demo projects in [the demo/ directory][demo-dir] * [JSFiddle][jsfiddle] -* [Demo for Node.js](/harttle/liquidjs/blob/master/demo/node/) +* [Demo for Node.js](/harttle/liquidjs/blob/master/demo/nodejs/) * [Demo in TypeScript](/harttle/liquidjs/blob/master/demo/typescript/) * [Demo for Browser Usage](/harttle/liquidjs/blob/master/demo/browser/) * [Demo for Express.js Usage](/harttle/liquidjs/blob/master/demo/express/) @@ -43,7 +43,7 @@ There's [a live demo][jsfiddle] on JSFiddle, and a list of demo projects in [the ## Documentation -The tutorials contains a list of articles for advanced use cases, performance optimization and extending liquidjs. +The tutorial contains a list of articles for advanced use cases, performance optimization and extending liquidjs. * [Render a Template File](/harttle/liquidjs/wiki/Render-a-File) * [Caching](/harttle/liquidjs/wiki/Caching) @@ -52,7 +52,6 @@ The tutorials contains a list of articles for advanced use cases, performance op * [Whitespace Control](/harttle/liquidjs/wiki/Whitespace-Control) * [Register Filters/Tags](/harttle/liquidjs/wiki/Register-Filters-Tags) * [Plugins](/harttle/liquidjs/wiki/Plugins) -* [Migrate to 9.0.0](/harttle/liquidjs/wiki/Migrate-to-9) The [API Reference](https://harttle.github.io/liquidjs/classes/_liquid_.liquid.html) provides detailed descriptions for classes, methods and properties. @@ -63,4 +62,6 @@ The [API Reference](https://harttle.github.io/liquidjs/classes/_liquid_.liquid.h * [Truthy and Falsy](/harttle/liquidjs/wiki/Truthy-and-Falsy) [jsfiddle]: https://jsfiddle.net/x43eb0z6/ -[demo-dir]: https://github.com/harttle/liquidjs/tree/master/demo \ No newline at end of file +[demo-dir]: https://github.com/harttle/liquidjs/tree/master/demo +[pp]: https://github.com/taylorhakes/promise-polyfill +[caniuse-promises]: http://caniuse.com/#feat=promises \ No newline at end of file diff --git a/Operators.md b/Operators.md index 949a56a..40dcaca 100644 --- a/Operators.md +++ b/Operators.md @@ -1,3 +1,18 @@ -Please refer to [the operators document](https://shopify.github.io/liquid/basics/operators/) from Shopify. Operators supported by LiquidJS are: +## Operators -`==`, `!=`, `>`, `<`, `>=`, `<=`, `or`, `and`, `contains`. +Liquid operators are very simple and different. According to the [operators document](https://shopify.github.io/liquid/basics/operators/) from Shopify, there're 2 types of operators supported: + +* Comparison operators: `==`, `!=`, `>`, `<`, `>=`, `<=` +* Logic operators: `or`, `and`, `contains` + +Thus numerical operators are not supported and you cannot even plus two numbers `{{a + b}}`. Actually `+` is a valid variable name. + +## Precedence + +The comparison operators have higher precedence than logic operators. + +## Associativity + +Logic operators are evaluated from right to left, see [shopify docs][operator-order]. + +[operator-order]: https://help.shopify.com/en/themes/liquid/basics/operators#order-of-operations diff --git a/Plugins.md b/Plugins.md index 90c5b88..ac59f4f 100644 --- a/Plugins.md +++ b/Plugins.md @@ -3,7 +3,9 @@ This article provides information about how to create and use a plugin ## Write a Plugin -We'll make a plugin to upper case every letter of the input, +A liquidjs plugin is simple function which takes the [Liquid class][liquid] as the first parameter and the Liquid instance for `this`. We can call liquidjs APIs on `this` to make certain changes, especially [register filters and tags][register]. + +Now we'll make a plugin to upper case every letter of the input, save the following snippet to `upup.js`: ```javascript @@ -32,11 +34,12 @@ engine ## Plugin List -See . +Since this library excludes certain features that are available on the Shopify platform but not on the [Shopify/liquid](https://github.com/Shopify/liquid/) repo, see . -Since this library excludes certain features that are available on the Shopify platform but not on the [Shopify/liquid](https://github.com/Shopify/liquid/) repo, see the following plugins that backfill those features: +Here's a list of plugins that backfill those features. Feel free to add yours, this file is publicly editable. * Sections Tags (WIP): https://github.com/harttle/liquidjs-section-tags * Color Filters: https://github.com/harttle/liquidjs-color-filters -> Feel free to add yours, this file is publicly editable. \ No newline at end of file +[liquid]: https://harttle.land/liquidjs/classes/_liquid_.liquid.html +[register]: /harttle/liquidjs/wiki/Register-Filters-Tags \ No newline at end of file diff --git a/Render-a-File.md b/Render-a-File.md index 332f20e..2e48b56 100644 --- a/Render-a-File.md +++ b/Render-a-File.md @@ -46,6 +46,39 @@ var engine = new 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. + +The `Liquid` constructor provides a [fs][fs] option to specify the file system implementation. It's supposed to be used to define customized template fetching logic, i.e. fetch template from a database table, like: + +```javascript +var engine = new Liquid({ + fs: { + readFileSync (file) { + return db.model('Template').findByIdSync(file).text + }, + await readFile (file) { + const template = await db.model('Template').findById(file) + return template.text + }, + existsSync () { + return true + }, + await exists () { + return true + }, + resolve(root, file, ext) { + return file + } + } +}); +``` + +[fs]: https://harttle.land/liquidjs/interfaces/_liquid_options_.liquidoptions.html#fs +[ifs]: https://github.com/harttle/liquidjs/blob/master/src/fs/ifs.ts +[fs-node]: https://github.com/harttle/liquidjs/blob/master/src/fs/node.ts +[fs-browser]: https://github.com/harttle/liquidjs/blob/master/src/fs/browser.ts [layout]: https://help.shopify.com/en/themes/liquid/tags/theme-tags#layout [include]: https://help.shopify.com/themes/liquid/tags/theme-tags#include [renderFile]: https://harttle.land/liquidjs/classes/_liquid_.liquid.html#renderfile