From 955b7971c0e033f0bd103d62d6bd55691e204196 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Tue, 11 Nov 2025 13:58:12 +0800 Subject: [PATCH] Support having new line and other whitespace after include filename (#834) --- src/parser/tokenizer.ts | 2 +- test/integration/tags/include.spec.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/parser/tokenizer.ts b/src/parser/tokenizer.ts index 2f638258f..0c2d86df7 100644 --- a/src/parser/tokenizer.ts +++ b/src/parser/tokenizer.ts @@ -422,7 +422,7 @@ export class Tokenizer { * readFileNameTemplate (options: NormalizedFullOptions): IterableIterator { const { outputDelimiterLeft } = options - const htmlStopStrings = [',', ' ', outputDelimiterLeft] + const htmlStopStrings = [',', ' ', '\r', '\n', '\t', outputDelimiterLeft] const htmlStopStringSet = new Set(htmlStopStrings) // break on ',' and ' ', outputDelimiterLeft only stops HTML token while (this.p < this.N && !htmlStopStringSet.has(this.peek())) { diff --git a/test/integration/tags/include.spec.ts b/test/integration/tags/include.spec.ts index a87e93e9a..d72bab861 100644 --- a/test/integration/tags/include.spec.ts +++ b/test/integration/tags/include.spec.ts @@ -265,6 +265,14 @@ describe('tags/include', function () { const html = liquid.renderFileSync('/current.html') return expect(html).toBe('FOO-') }) + it('should support Jekyll style include with other whitespace before filename', function () { + mock({ + '/current.html': '{% include bar/foo.html\r\n\ntitle="TITLE"\tcontent="FOO" %}', + '/bar/foo.html': '{{include.title}}={{include.content}}-{{content}}' + }) + const html = liquid.renderFileSync('/current.html') + return expect(html).toBe('TITLE=FOO-') + }) it('should support multiple parameters', function () { mock({ '/current.html': '{% include bar/foo.html header="HEADER" content="CONTENT" %}',