liquidjs
liquidjs copied to clipboard
Add global jekyll style variable parsing
trafficstars
Hi, currently when we use new Hash(tagToken.args, true) we can support jekyll style variables in our custom tags, however when using built-in tags, such options is not possible for example, {% render "tmp", cur=var1 %}, as some teams have strong react background, and liquidjs Hash already support jekyll style variables, please make hash to default to a value defined in the options instead of hardcoding one:
// tokenizer.ts
readHash (jekyllStyle?: boolean): HashToken | undefined {
this.skipBlank()
if (this.peek() === ',') ++this.p
const begin = this.p
const name = this.readNonEmptyIdentifier()
if (!name) return
let value
this.skipBlank()
const sep = jekyllStyle ? '=' : ':' /* Make this read from options passed to the engine */
// ex:
// const sep = jekyllStyle ? '=' : seperatorFromEngineOptions
if (this.peek() === sep) {
++this.p
value = this.readValue()
}
return new HashToken(this.input, begin, this.p, name, value, this.file)
}
by making this new seperatorFromEngineOptions default to ':' I think backward compatibility will be preserved.
Please try setting keyValueSeparator option to =.