mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-19 06:20:38 -07:00
Updated Whitespace Control (markdown)
+20
-11
@@ -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: <https://github.com/harttle/liquidjs>
|
||||
[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
|
||||
Reference in New Issue
Block a user