-
Notifications
You must be signed in to change notification settings - Fork 0
/
icanhaz.js
3 lines (3 loc) · 1.13 KB
/
icanhaz.js
1
2
3
(function(){(function(){var b={VERSION:"0.10",templates:{},$:"undefined"!==typeof window?window.jQuery||window.Zepto||null:null,addTemplate:function(a,d){if("object"===typeof a)for(var c in a)this.addTemplate(c,a[c]);else b[a]?console.error("Invalid name: "+a+"."):b.templates[a]?console.error('Template "'+a+' " exists'):(b.templates[a]=d,b[a]=function(c,d){var c=c||{},f=Mustache.to_html(b.templates[a],c,b.templates);return b.$&&!d?b.$(f):f})},clearAll:function(){for(var a in b.templates)delete b[a];
b.templates={}},refresh:function(){b.clearAll();b.grabTemplates()},grabTemplates:function(){var a,d=document.getElementsByTagName("script"),c,e=[];for(a=0,l=d.length;a<l;a++)if((c=d[a])&&c.innerHTML&&c.id&&("text/html"===c.type||"text/x-icanhaz"===c.type))b.addTemplate(c.id,"".trim?c.innerHTML.trim():c.innerHTML.replace(/^\s+/,"").replace(/\s+$/,"")),e.unshift(c);for(a=0,l=e.length;a<l;a++)e[a].parentNode.removeChild(e[a])}};"undefined"!==typeof require?module.exports=b:window.ich=b;"undefined"!==
typeof document&&(b.$?b.$(function(){b.grabTemplates()}):document.addEventListener("DOMContentLoaded",function(){b.grabTemplates()},!0))})()})();