Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to pass boolean values from helper to template #589

Open
kal800 opened this issue Aug 30, 2024 · 0 comments
Open

[Question] How to pass boolean values from helper to template #589

kal800 opened this issue Aug 30, 2024 · 0 comments
Labels

Comments

@kal800
Copy link

kal800 commented Aug 30, 2024

I've got a HTML template which should apply certain content based on the language version. For "pl-PL" a polish version and for any other english. Now, I'm passing language parameter in report request. I've written simple handlebars helper:

Handlebars.RegisterHelper("IsPolish", (writer, context, parameters) =>
 {
     if (req.Lang == "pl-PL")
        writer.WriteSafeString(true);
     else writer.WriteSafeString(false);
 });

The helper returns correct value, but Handlebars does not interpret it correctly:

    <td style="width:35%">{{IsPolish}}</td>
    <td style="width:15%">{{#if (IsPolish)}}TRUE{{else}}FALSE{{/if}}</td>

After rendering it shows:

<td style="width:35%">False</td>
<td style="width:15%">TRUE</td>

From what I've read, the Handlebars is case sensitive and .net serializes boolean values with first capital letter first, but I do not have a clue how to overcome it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant