3 /* applies the tpl (a selector of a template) to the data and puts it as the html of the object
4 * it triggers two events
5 * assign (to be able to alter the data)
6 * render (after the html has been added to the dom) to allow jquery event initialisations
7 * options.method = html (or after or before or any html injection jquery method
11 $.fn
.crmTemplate = function(tpl
,data
,options
) {
13 var settings
= $.extend( {
17 var mustacheTpl
= $(tpl
);
18 mustacheTpl
.trigger ('assign',data
);
20 return this.each(function() {
21 //$(this).html($.mustache(mustacheTpl.html(),data)).trigger('render',data);
22 $(this)[settings
.method
]($.mustache(mustacheTpl
.html(),data
)).trigger('render',data
);
23 //mustacheTpl.trigger ('render',data);