2015-04-30 22 views
0

调用options.inverse(this)会导致一个句柄块帮助程序执行其else块。我怎么能让它无所事事?我遇到了3起案件,我希望非数字案件什么也不做。这似乎并不奏效。我该怎么做?Handlebars块帮手noop第三种情况

module.exports.register = function (Handlebars) { 
    Handlebars.registerHelper('example', function(test, options) { 
    return typeof test != 'number' ? '' : options[test ? 'fn' : 'inverse'](this); 
    }); 
}; 

回答

0

为了实现3例,你可以嵌套另一个if块:

{{#if condition}} 
    {{!--First case--}} 
{{else}} 
    {{#if someOtherCOndition}} 
     {{!--Second case--}} 
    {{else}} 
     {{!--Third case--}} 
    {{/if}} 
{{/if}}