UNPKG

ziggurat.js

Version:

a tiny modular js library for templates and other shorthands

2 lines (1 loc) 417 B
zg.create=function(e,t){var n,s=zg.queryone("zg-template#"+e);if(s==null)throw new TypeError("no such template with name "+e);return n=function(e,t){var s,o,i,c=e.cloneNode(!0),a=[],r=c.childNodes;for(o=0,i=r.length;o<i;o++){switch(s=r[o],s.nodeName.toLowerCase()){case"zg-var":s=document.createTextNode(zg.deepfind(t,s.innerHTML))}s.children!=null&&s.replaceChildren(...n(s,t)),a.push(s)}return a},HTML.div(n(s,t))}