Logic in Handlebars if/else statement?

后端 未结 3 865
清歌不尽
清歌不尽 2020-12-22 12:03

Forgive me for the stupid question, I know you\'re not supposed to put logic in handlebars expressions, but I\'m new to this and I\'m not sure how to get around it.

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-22 12:49

    You can register a helper

    
    
    Handlebars.registerHelper("equals", function(string1 ,string2, options) {
        if (string1 === string2) {
            return options.fn(this);
        } else {
            return options.inverse(this);
        }
    });
    

提交回复
热议问题