Skip to content

Commit 955b797

Browse files
Support having new line and other whitespace after include filename (#834)
1 parent 8686876 commit 955b797

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/parser/tokenizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ export class Tokenizer {
422422

423423
* readFileNameTemplate (options: NormalizedFullOptions): IterableIterator<TopLevelToken> {
424424
const { outputDelimiterLeft } = options
425-
const htmlStopStrings = [',', ' ', outputDelimiterLeft]
425+
const htmlStopStrings = [',', ' ', '\r', '\n', '\t', outputDelimiterLeft]
426426
const htmlStopStringSet = new Set(htmlStopStrings)
427427
// break on ',' and ' ', outputDelimiterLeft only stops HTML token
428428
while (this.p < this.N && !htmlStopStringSet.has(this.peek())) {

test/integration/tags/include.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ describe('tags/include', function () {
265265
const html = liquid.renderFileSync('/current.html')
266266
return expect(html).toBe('FOO-')
267267
})
268+
it('should support Jekyll style include with other whitespace before filename', function () {
269+
mock({
270+
'/current.html': '{% include bar/foo.html\r\n\ntitle="TITLE"\tcontent="FOO" %}',
271+
'/bar/foo.html': '{{include.title}}={{include.content}}-{{content}}'
272+
})
273+
const html = liquid.renderFileSync('/current.html')
274+
return expect(html).toBe('TITLE=FOO-')
275+
})
268276
it('should support multiple parameters', function () {
269277
mock({
270278
'/current.html': '{% include bar/foo.html header="HEADER" content="CONTENT" %}',

0 commit comments

Comments
 (0)