liquid-rust icon indicating copy to clipboard operation
liquid-rust copied to clipboard

Whitespace trimming doesn't work like examples in Liquid docs

Open agersant opened this issue 5 years ago • 6 comments

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.

agersant avatar Jan 06 '20 00:01 agersant

Thanks for reporting this! I'm going to be a bit busy for the next month or so with having just moved, so it'll be a bit before I can get to this though I could help you if you want to dig into it.

epage avatar Jan 06 '20 16:01 epage

Thank you for the quick answer! I am in no rush at all so I can wait as long as you need.

agersant avatar Jan 06 '20 19:01 agersant

I'm new to rust but would be interested in taking a look at this issue; seems like it could be straight-forward to track down. Please let me know if you are interested in the help.

JGailor avatar Mar 14 '20 21:03 JGailor

I'm new to rust but would be interested in taking a look at this issue; seems like it could be straight-forward to track down. Please let me know if you are interested in the help.

Yes, would love the help.

epage avatar Mar 14 '20 22:03 epage

Great. I'll start taking a look today. I've read through the contributing guidelines, but if there are any other details to be aware of please let me know.

JGailor avatar Mar 16 '20 16:03 JGailor

Nah, pretty straightforward. Not sure if its mentioned but we do use conventional commit style which the CI enforces. I try to not make too big of a deal out of it because not everyone is comfortable enough with git to clean things up. I usually tell people tell people how to clean it up or give them the option of me cleaning it up for them

epage avatar Mar 16 '20 17:03 epage