From 6057fc9e6a6d5f9e405cdb21ea58e9f4e074e25a Mon Sep 17 00:00:00 2001 From: Jun Yang Date: Mon, 30 Oct 2017 00:49:20 +0800 Subject: [PATCH] Updated Whitespace Control (markdown) --- Whitespace-Control.md | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/Whitespace-Control.md b/Whitespace-Control.md index adb513c..2d86f64 100644 --- a/Whitespace-Control.md +++ b/Whitespace-Control.md @@ -1,5 +1,4 @@ -Like other variants of Liquid, liquidjs supports whitespace control markups. -In addition, you can change the default behaviors during construction. +Like Shopify/liquid, liquidjs provides whitespace control via `-` markups and engine options. ## via Markups @@ -10,6 +9,7 @@ For example: ```liquid {% assign author = "harttle" %} {{ author }} + ``` Outputs: @@ -17,14 +17,15 @@ Outputs: ``` harttle + ``` You can include hyphens in your tag syntax (`{{-`, `-}}`, `{%-`, `-%}`) to strip whitespace from left or right. For example: ```liquid -{% assign author = "harttle" -%} -{{ author }} +{%- assign author = "harttle" -%} +{{- author -}} ``` Outputs: @@ -37,14 +38,22 @@ harttle ## via Options -[liquidjs][liquidjs] will **NOT** trim any whitespace by default. -By specifying `options.trim_left` or `options.trim_right`, -you can change this default behavior. +To enable whitespace control without spreading changes, use these options: -Note that the `trim_right` and `trim_left` only change the behavior of `{{ }}` and `{% %}`, -which means `{{-` (or `{%-`) will always trim whitespace from the left, -and `-}}` (or `-%}`) will always trim whitespace from the right regardless of the `trim_left` and `trim_right` options. +* `trim_tag_left` +* `trim_tag_right` +* `trim_value_right` +* `trim_value_right` -For details of these options, see: +[liquidjs][liquidjs] will **NOT** trim any whitespace by default, i.e. above options all default to `false`. +For details of these options, see the [README](https://github.com/harttle/liquidjs). +## Greedy Mode + +In greedy mode (enabled by the [greedy option][liquidjs]), +all consecutive whitespace chars (including `\n`) will be trimmed. +Greedy mode is enabled by default to be compliant with [shopify/liquid][shopify/liquid]. +(If I'm wrong here, please file an issue) + +[shopify/liquid]: https://github.com/Shopify/liquid [liquidjs]: https://github.com/harttle/liquidjs \ No newline at end of file