Skip to content

liquidMethodMissing without a key #657

Answered by harttle
AsadCSE asked this question in Q&A
Discussion options

You must be logged in to vote

Create a runkit snippet for your case: https://runkit.com/embed/2is7di4mc7kk The trick is use toValue()

const {Liquid, Drop} = require('liquidjs')
class CollestionDrop extends Drop {
    liquidMethodMissing(key) {
        return [key, key.toUpperCase()]
    }
    valueOf() {
        return ["default", "collection"]
    }
}
const context = {
    collection: new CollestionDrop()
}
const engine = new Liquid()
const template = `
collection: {{collection | join: ","}}
collection.foo: {{collection.foo | join: "," }}"`
engine.parseAndRender(template, context)

And here's the newly created doc for Drops: https://liquidjs.com/tutorials/drops.html

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AsadCSE
Comment options

Answer selected by AsadCSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants