1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
By default, whitespace before a block start tag or after a block end tag
is retained. By suffixing the start tag or prefixing the end tag with a
dash, the leading or trailing whitespace is trimmed respectively.
-- Expect stdout --
Whitespace control applies to all block types:
Comment before: | |, after: | |, both: ||
Statement before: |test |, after: | test|, both: |test|
Expression before: |test |, after: | test|, both: |test|
By default whitespace around a block is retained.
Leading whitespace can be trimmed like this.
The same applies to trailing whitespace.
It is also possible to trim bothleading and trailingwhitespace.
Stripping works across multiple lines as well:test
Likewise, stripping over multiple lines of trailing whitespace works as
expected too.This is after the block.
-- End --
-- Testcase --
Whitespace control applies to all block types:
Comment before: | {#- test #} |, after: | {#- test #} |, both: | {#- test -#} |
Statement before: | {%- print("test") %} |, after: | {%+ print("test") -%} |, both: | {%- print("test") -%} |
Expression before: | {{- "test" }} |, after: | {{ "test" -}} |, both: | {{- "test" -}} |
By default whitespace {{ "around a block" }} is retained.
Leading whitespace can be trimmed {#- note the leading dash #} like this.
The same applies to {# note the trailing dash -#} trailing whitespace.
It is also possible to trim both {{- "leading and trailing" -}} whitespace.
Stripping works across multiple lines as well:
{%-
/* The word "test" will be printed after "well:" above */
print("test")
%}
Likewise, stripping over multiple lines of trailing whitespace works as
expected too.
{#- Any whitespace after "expected too." and before "This is after the block" will be trimmed. -#}
This is after the block.
-- End --
|