Skip to content

Whitespace trimming doesn't work like examples in Liquid docs #377

Open
@agersant

Description

@agersant

liquid-rust version: 0.19
rust version: nightly
OS: Windows

When using {%- -%} to open and close a tag, some unwanted whitespace still appears in the rendered document.
Looking at the example at the bottom of this page for reference, I would expect the following template render to look correctly indented:

return {
	type = "spritesheet",
	content = {
		texture = "{{ sheet_image | replace: "\", "/" }}",
		frames = {
			{%- for frame in frames -%}
			frame_{{ frame.index }} = { x = {{ frame.x }}, y = {{ frame.y }}, w = {{ frame.width }}, h = {{ frame.height }}, },
			{%- endfor -%}
		},
	},
};

Instead, the result looks like:

return {
	type = "spritesheet",
	content = {
		texture = "assets/texture/sprite/duran.png",
		frames = {
						frame_0 = { x = 0, y = 0, w = 33, h = 27, },
						frame_1 = { x = 33, y = 0, w = 25, h = 44, },
						frame_2 = { x = 58, y = 0, w = 35, h = 34, },
						frame_3 = { x = 93, y = 0, w = 35, h = 31, },
						frame_4 = { x = 128, y = 0, w = 25, h = 29, },
						frame_5 = { x = 153, y = 0, w = 19, h = 41, },
						frame_6 = { x = 172, y = 0, w = 20, h = 43, },
						frame_7 = { x = 192, y = 0, w = 20, h = 44, },
						frame_8 = { x = 212, y = 0, w = 16, h = 37, },
		},
	},
};

Notice the extra indentation before each entry in the frames struct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugNot as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions