Skip to content

fix: don't let trailing whitespace control strip a partial's leading whitespace - #2145

Open
nagibatorz wants to merge 2 commits into
Shopify:mainfrom
nagibatorz:nagibatorz/whitespace-control-partial-2140
Open

nagibatorz wants to merge 2 commits into
Shopify:mainfrom
nagibatorz:nagibatorz/whitespace-control-partial-2140

Conversation

@nagibatorz

Copy link
Copy Markdown

Fixes #2140. A template ending in -%} or -}} leaves trim_whitespace set on the shared parse context, and PartialCache.load parsed partials with that context, stripping the partial's leading whitespace. Clear the flag while parsing the partial and restore it afterwards. Validation: new test fails on clean main and passes with the fix; full suite 1063 runs, 0 failures.

…espace

A template ending in -%} or -}} leaves parse_context.trim_whitespace
set, and PartialCache.load parses the partial with the parent
template's parse context, so the partial's leading whitespace is
stripped. Repro for Shopify#2140.
A template ending in -%} or -}} leaves trim_whitespace set on the
shared parse context, and PartialCache.load parsed partials with that
context, stripping the partial's leading whitespace. Clear the flag
while parsing the partial and restore it afterwards. Fixes Shopify#2140.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A -%} or -}} at the end of a template strips the leading whitespace of the partials it renders

1 participant