1

I have the following helper for handlebars.net:

Handlebars.RegisterHelper("#is",
    (writer, context, args) =>
    {

        string val1 = args[0].ToString();
        string val2 = args[1].ToString();

        if (val1 == val2)
        {
            //how to get block output
        }

    });

I am trying to test it on the following html, but I am not sure how to write out the content between {#is} and {/is} if it is true:

 <div style="text-align: right;">
        {{#each TeamMembers}}
        {{#is this.Title 'Manager'}}
        {{ this.Name }}<br />
        {{ this.PersonalEmail }}<br />
        {{ this.Phone }}<br />
        {{/is}}
        {{/each}}
    </div>

1 Answer 1

2

Figured it out using a different signature:

 Handlebars.RegisterHelper("is",
        (writer,options, context, args) =>
        {

            string val1 = args[0].ToString();
            string val2 = args[1].ToString();

            if (val1 == val2)
            {
                options.Template(writer, (object)context);
            }

        });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.