如何输出带有把手点网条件助手的块? [英] How to output block with handlebars dot net conditional helper?

查看:85
本文介绍了如何输出带有把手点网条件助手的块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为handlebars.net提供了以下帮助程序:

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
        }

    });

我正在尝试在以下html上对其进行测试,但是我不确定如何在{#is} and {/is}之间写出正确的内容:

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>

推荐答案

使用其他签名将其找出来:

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

        });

这篇关于如何输出带有把手点网条件助手的块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆