如何用车把点网状态辅助输出块?

时间:2017-09-15 15:59:58

标签: handlebars.net

我为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
        }

    });

我试图在下面的html上测试它,但我不知道如果它是真的,如何写出{#is} and {/is}之间的内容:

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

1 个答案:

答案 0 :(得分:2)

使用不同的签名计算出来:

 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);
            }

        });