-
Notifications
You must be signed in to change notification settings - Fork 236
Closed
US-EPA-CAMD/easey-quartz-scheduler
#284Description
Scenario
Handlebars.js
Template
{{^test input}}empty{{else}}not empty{{/test}}Helper
Handlebars.registerHelper("test", function(conditional, options) {
if (conditional) {
return options.fn(conditional);
} else {
return options.inverse(conditional);
}
});Input & result
{ "input": 1 } // Result: not empty{ "input": 0 } // Result: emptyHandlebars.Net
[Fact]
public void BlockHelperWithInversion()
{
string source = @"{{^test input}}empty{{else}}not empty{{/test}}";
var handlebars = Handlebars.Create();
handlebars.RegisterHelper("test", (output, options, context, arguments) =>
{
if (HandlebarsUtils.IsTruthy(arguments[0]))
{
options.Template(output, context);
}
else
{
options.Inverse(output, context);
}
});
var template = handlebars.Compile(source);
Assert.Equal("empty", template(null));
Assert.Equal("empty", template(new { otherInput = 1 }));
Assert.Equal("not empty", template(new { input = 1 }));
}Actual result
- ❌
^testdetected asHandlebarsHelperinstead ofHandlebarsBlockHelper - ❌
^testtried to be late-bounded - ❌
Template references a helper that is not registered. Could not find helper '^test'exception thrown
Expected result
- matches to Handlebars.js behaviour.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels