jquery.handlebars.js
375 Bytes
/**
* handlebars插件
*/
(function($) {
/**
* handlebars自定义插件
*
* @param template
* @param data
*/
$.fn.handlebars = function(template, data) {
var compiled = {};
if (template instanceof jQuery) {
template = $(template).html();
}
compiled[template] = Handlebars.compile(template);
$(this).html(compiled[template](data));
}
})(jQuery);