mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
fix: allow quoted variable name in capture, fixes #252
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { Tokenizer, assert, Template, Context, TagImplOptions, TagToken, TopLevelToken } from '../../types'
|
||||
import { evalQuotedToken } from '../../render/expression'
|
||||
|
||||
export default {
|
||||
parse: function (tagToken: TagToken, remainTokens: TopLevelToken[]) {
|
||||
const tokenizer = new Tokenizer(tagToken.args)
|
||||
this.variable = tokenizer.readWord().content
|
||||
this.variable = readVariableName(tokenizer)
|
||||
assert(this.variable, () => `${tagToken.args} not valid identifier`)
|
||||
|
||||
this.templates = []
|
||||
@@ -22,3 +23,10 @@ export default {
|
||||
ctx.bottom()[this.variable] = html
|
||||
}
|
||||
} as TagImplOptions
|
||||
|
||||
function readVariableName (tokenizer: Tokenizer) {
|
||||
const word = tokenizer.readWord().content
|
||||
if (word) return word
|
||||
const quoted = tokenizer.readQuoted()
|
||||
if (quoted) return evalQuotedToken(quoted)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user