-
Notifications
You must be signed in to change notification settings - Fork 225
Open
Labels
Description
I am using the #if
helper, but it is not working as expected. Below is my equal
helper code (exception handling removed for clarity):
_handlebars.RegisterHelper("equal", (writer, context, parameters) =>
{
if (parameters.Length != 2)
{
throw new TemplateServiceException(
"The equal helper requires exactly two parameters.");
}
var firstDecimal = Convert.ToDecimal(parameters[0], CultureInfo.InvariantCulture);
var secondDecimal = Convert.ToDecimal(parameters[1], CultureInfo.InvariantCulture);
writer.WriteSafeString(firstDecimal == secondDecimal);
});
Template:
<ul class="list-buffer">
Result of equal helper: {{equal (record_count VerifiedList) 1}}
{{#if (equal (record_count VerifiedList) 1)}}
is ready to pay.
{{else}}
are ready to pay.
{{/if}}
</ul>
I am printing the result of {{equal (record_count VerifiedList) 1}}
and it correctly shows False
. However, my {{#if...
condition is not rendering the else part in the template output. It prints "is ready to pay." even though VerifiedList has 2 records and record_count
returns it correctly.
Could the issue be that the equal
helper is writing "False" as a string
instead of a boolean
?
Output