如何在自定义 if 帮助程序中从父对象访问对象?

How to access object from parent in custom if helper?

ifequal 助手中的 ../../Message.NotAvailable 似乎不起作用,但如果我提供一个字符串 "Hello" 来与类型进行比较,它可以正常工作并进入循环

{{#ifequal type ../../Message.NotAvailable}}
    <li id="{{id}}"><a href="#">{{../../../Message.NotAvailable}}</a> </li>
    {{/ifequal}}

我的帮手:

  Handlebars.registerHelper('ifequal', function(value1, value2, options) {
    if(value1 === value2) {
        return options.fn(this);
    }
    return options.inverse(this);
});

编辑:

我试过从变量中删除 ../../ 似乎也不起作用。

如果 Message.NotAvailable 在父模板范围内,使用 ../Message.NotAvailable

The ../ path segment references the parent template scope, not one level up in the context.