官网: http://handlebarsjs.com/

最近想学Ember.js, 了解到Handlebars模板引擎. 相比Python Mako, Jinja2 跟简单. 自定义 Block 非常的方便Handlebars.registerHelper(name, function() { ... });

(function($) {
  var compiled = {};
  $.fn.handlebars = function(template, data) {
    if (template instanceof jQuery) {
      template = $(template).html();
    }
    compiled[template] = Handlebars.compile(template);
    this.html(compiled[template](data));
  };
})(jQuery);

dreambei
132 声望4 粉丝