In Handlebars.Net, if there is no matching field, it just places a blank there.
string source = @"My name is {{Name}} and I work at {{Job}}";
var template = Handlebars.Compile(source);
var data = new {
Job = "Walmart"
};
var result = template(data);
Results in this because the {{Name}}
is not in the data.
My name is and I work at Walmart
Is there a setting to say, just don't replace it if the data field does not exist?
I'd like for it to return:
My name is {{Name}} and I work at Walmart
There are two options:
Supported in 1.x: use
UnresolvedBindingFormatter
handlebars.Configuration.UnresolvedBindingFormatter = "('{0}' is undefined)";
Supported starting from 2.0.0-preview-1: use
helperMissing
hookFor more details see this GitHub issue.