providing fallback value if no match found.
ehxxn opened this issue · comments
Ehsan sarshar commented
I am trying to use mustache to replace all placeholder inside JSON with the actual value and then parse them.
but if there is no match then mustache render an empty space with is an invalid JSON.
can I render my own custom value as fallback in no match found.
here is an example
let template = "{name: {{name}}, age: {{age}}}"
let invalidJSON = Mustache.render(template, {name: "Ehsan"});
console.log(json)
// {name: Ehsan, age: }