Handlebars.js learning

官网: 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
    原文地址: https://segmentfault.com/a/1190000000577542
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞