Handlebarsjs check if a string is equal to a value

后端 未结 13 773
挽巷
挽巷 2020-12-08 18:23

Is it possible in Handlebars to check if a string is equal to another value without registering a helper? I can\'t seem to find anything relevant to this in the Handlebars r

13条回答
  •  情歌与酒
    2020-12-08 19:25

    Node.js add this in server.js

    const isEqual = function(a, b, opts) {
      if (a == b) {
        return opts.fn(this) 
      } else { 
        return opts.inverse(this) 
      } 
    }
    
    var hbs = require('hbs');
    hbs.registerHelper('if_eq', isEqual);
    

提交回复
热议问题