mirror of
https://github.com/harttle/liquidjs.git
synced 2026-10-03 09:05:14 -07:00
Support having new line and other whitespace after include filename (#834)
This commit is contained in:
@@ -422,7 +422,7 @@ export class Tokenizer {
|
|||||||
|
|
||||||
* readFileNameTemplate (options: NormalizedFullOptions): IterableIterator<TopLevelToken> {
|
* readFileNameTemplate (options: NormalizedFullOptions): IterableIterator<TopLevelToken> {
|
||||||
const { outputDelimiterLeft } = options
|
const { outputDelimiterLeft } = options
|
||||||
const htmlStopStrings = [',', ' ', outputDelimiterLeft]
|
const htmlStopStrings = [',', ' ', '\r', '\n', '\t', outputDelimiterLeft]
|
||||||
const htmlStopStringSet = new Set(htmlStopStrings)
|
const htmlStopStringSet = new Set(htmlStopStrings)
|
||||||
// break on ',' and ' ', outputDelimiterLeft only stops HTML token
|
// break on ',' and ' ', outputDelimiterLeft only stops HTML token
|
||||||
while (this.p < this.N && !htmlStopStringSet.has(this.peek())) {
|
while (this.p < this.N && !htmlStopStringSet.has(this.peek())) {
|
||||||
|
|||||||
@@ -265,6 +265,14 @@ describe('tags/include', function () {
|
|||||||
const html = liquid.renderFileSync('/current.html')
|
const html = liquid.renderFileSync('/current.html')
|
||||||
return expect(html).toBe('FOO-')
|
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 () {
|
it('should support multiple parameters', function () {
|
||||||
mock({
|
mock({
|
||||||
'/current.html': '{% include bar/foo.html header="HEADER" content="CONTENT" %}',
|
'/current.html': '{% include bar/foo.html header="HEADER" content="CONTENT" %}',
|
||||||
|
|||||||
Reference in New Issue
Block a user