CityWebConsultants / Iris

Modular content management and web application framework built with Node.js and MongoDB
http://irisjs.org
Other
9 stars 7 forks source link

Add in optional handlebars helper library for common functions #99

Closed facascante closed 8 years ago

facascante commented 8 years ago

  Handlebars.registerHelper('compare', function (lvalue, operator, rvalue, options) {
    if (arguments.length < 4) {
      throw new Error("Handlerbars Helper 'compare' needs 3 parameters");
    }

    var result = eval("'" + lvalue + "' " + operator + " '" + rvalue + "'");
    if (result) {
      return options.fn(this);
    } else {
      return options.inverse(this);
    }
  });
FilipNest commented 8 years ago

Is it worth putting something like https://github.com/elving/swag in? It's loads of Handlebars helpers.

facascante commented 8 years ago

yeah this is better. those function are just generic utility that is a must have of server side template. can we add?

FilipNest commented 8 years ago

How about an Iris module called handlebars_swag or something like that that adds this in the extra folder for now?

facascante commented 8 years ago

thats fine. i need equal helper :)

FilipNest commented 8 years ago

Going to do this as a contrib module as that leaves it up to the user. Can close this or wait until done.