1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-26 19:44:45 +01:00

Stop trimming ASAP

This commit is contained in:
Daniil Gentili 2022-01-06 14:26:10 +01:00
parent 5cbe290051
commit 3c60e26a82
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
3 changed files with 5 additions and 2 deletions

View File

@ -25,6 +25,9 @@ func (tw *trimWriter) Write(b []byte) (int, error) {
n := len(b)
if tw.trimRight {
b = bytes.TrimLeftFunc(b, unicode.IsSpace)
if n != 0 {
tw.trimRight = false
}
} else if tw.buf.Len() > 0 {
if err := tw.Flush(); err != nil {
return 0, err

View File

@ -36,7 +36,7 @@ func TestIncludeTag(t *testing.T) {
buf = new(bytes.Buffer)
err = render.Render(root, buf, includeTestBindings, config)
require.NoError(t, err)
require.Equal(t, "value", strings.TrimSpace(buf.String()))
require.Equal(t, "test value", strings.TrimSpace(buf.String()))
// errors
root, err = config.Compile(`{% include 10 %}`, loc)

View File

@ -1 +1 @@
{% if test %}{{ var }}{% endif %}
{%- assign myVar = "test" -%}test {% if test %}{{ var }}{% endif %}