UNPKG

1.29 kBJavaScriptView Raw
1!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){function e(e){return e.replace(/(?:^|\n)([^@]*)@?/gm,function(e,n){return"\ncall __ht_template_result.push(`"+(" "+n).replace(/([^\\])\$\{/g,"$1$${escape html ").substring(1)+"`)\n"})}var n;(n=window._hyperscript).addCommand("render",function(r,t,a){if(a.matchToken("render")){var i=r.requireElement("expression",a),o={};return a.matchToken("with")&&(o=r.parseElement("namedArgumentList",a)),{args:[i,o],op:function(r,a,o){if(!(a instanceof Element))throw new Error(i.sourceFor()+" is not an element");return console.log(e(a.innerHTML)),r.result=function(e,r){var t=[];return n.evaluate(e,Object.assign({__ht_template_result:t},r)),t.join("")}(e(a.innerHTML),o),t.findNext(this,r)}}}}),n.addLeafExpression("escape",function(e,n,r){if(r.matchToken("escape")){var t=r.matchTokenType("IDENTIFIER").value,a=r.matchToken("unescaped");return{args:[e.requireElement("expression",r)],op:function(e,n){if(a)return n;if(void 0===n)return"";if("html"===t)return String(n).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\x22/g,"&quot;").replace(/\x27/g,"&#039;");throw new Error("Unknown escape: "+t)},evaluate:function(e){return n.unifiedEval(this,e)}}}})});
2//# sourceMappingURL=template.min.js.map