mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
fix: empty tagToken.args since 10.20.0, fixes #796
This commit is contained in:
@@ -5,6 +5,7 @@ import type { NormalizedFullOptions } from '../liquid-options'
|
|||||||
export class TagToken extends DelimitedToken {
|
export class TagToken extends DelimitedToken {
|
||||||
public name: string
|
public name: string
|
||||||
public tokenizer: Tokenizer
|
public tokenizer: Tokenizer
|
||||||
|
public readonly args: string;
|
||||||
public constructor (
|
public constructor (
|
||||||
input: string,
|
input: string,
|
||||||
begin: number,
|
begin: number,
|
||||||
@@ -20,9 +21,6 @@ export class TagToken extends DelimitedToken {
|
|||||||
this.name = this.tokenizer.readTagName()
|
this.name = this.tokenizer.readTagName()
|
||||||
this.tokenizer.assert(this.name, `illegal tag syntax, tag name expected`)
|
this.tokenizer.assert(this.name, `illegal tag syntax, tag name expected`)
|
||||||
this.tokenizer.skipBlank()
|
this.tokenizer.skipBlank()
|
||||||
}
|
this.args = this.tokenizer.input.slice(this.tokenizer.p, this.contentRange[1])
|
||||||
|
|
||||||
get args (): string {
|
|
||||||
return this.tokenizer.input.slice(this.tokenizer.p, this.contentRange[1])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { TopLevelToken, TagToken, Tokenizer, Context, Liquid, Drop, toValueSync, LiquidError } from '../..'
|
import { TopLevelToken, TagToken, Tokenizer, Context, Liquid, Drop, toValueSync, LiquidError, IfTag } from '../..'
|
||||||
const LiquidUMD = require('../../dist/liquid.browser.umd.js').Liquid
|
const LiquidUMD = require('../../dist/liquid.browser.umd.js').Liquid
|
||||||
|
|
||||||
describe('Issues', function () {
|
describe('Issues', function () {
|
||||||
@@ -558,4 +558,11 @@ describe('Issues', function () {
|
|||||||
CSharp <sup>2</sup> Posts:page2,page4,
|
CSharp <sup>2</sup> Posts:page2,page4,
|
||||||
CPP <sup>1</sup> Posts:page0,`)
|
CPP <sup>1</sup> Posts:page0,`)
|
||||||
})
|
})
|
||||||
|
it('if tag condition, the token args is empty #796', () => {
|
||||||
|
const tpl = 'Hello, {% if name %} {{ name }} {% else %} user {% endif %}'
|
||||||
|
const engine = new Liquid()
|
||||||
|
const parsed = engine.parse(tpl)
|
||||||
|
const ifToken = parsed[1]
|
||||||
|
expect((ifToken as IfTag).token.args).toEqual('name')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user