-
Notifications
You must be signed in to change notification settings - Fork 1
/
doT.min.js
1 lines (1 loc) · 3.72 KB
/
doT.min.js
1
!function(){"use strict";var u={name:"doT",version:"1.1.1",templateSettings:{evaluate:/\{\{([\s\S]+?(\}?)+)\}\}/g,interpolate:/\{\{=([\s\S]+?)\}\}/g,encode:/\{\{!([\s\S]+?)\}\}/g,use:/\{\{#([\s\S]+?)\}\}/g,useParams:/(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g,define:/\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,defineParams:/^\s*([\w$]+):([\s\S]+)/,conditional:/\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g,iterate:/\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g,varname:"it",strip:!0,append:!0,selfcontained:!1,doNotSkipEncoded:!1},template:void 0,compile:void 0,log:!0};!function(){if("object"!=typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){window.globalThis=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;if(void 0!==this)return this;throw new Error("Unable to locate global `this`")}()}}(),u.encodeHTMLSource=function(e){var t={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},n=e?/[&<>"'\/]/g:/&(?!#?\w+;)|<|>|"|'|\//g;return function(e){return e?e.toString().replace(n,function(e){return t[e]||e}):""}},"undefined"!=typeof module&&module.exports?module.exports=u:"function"==typeof define&&define.amd?define(function(){return u}):globalThis.doT=u;var l={append:{start:"'+(",end:")+'",startencode:"'+encodeHTML("},split:{start:"';out+=(",end:");out+='",startencode:"';out+=encodeHTML("}},d=/$^/;function s(e){return e.replace(/\\('|\\)/g,"$1").replace(/[\r\t\n]/g," ")}u.template=function(e,t,n){var r,o,i=(t=t||u.templateSettings).append?l.append:l.split,a=0,c=t.use||t.define?function r(o,e,i){return("string"==typeof e?e:e.toString()).replace(o.define||d,function(e,r,t,n){return 0===r.indexOf("def.")&&(r=r.substring(4)),r in i||(":"===t?(o.defineParams&&n.replace(o.defineParams,function(e,t,n){i[r]={arg:t,text:n}}),r in i||(i[r]=n)):new Function("def","def['"+r+"']="+n)(i)),""}).replace(o.use||d,function(e,t){o.useParams&&(t=t.replace(o.useParams,function(e,t,n,r){if(i[n]&&i[n].arg&&r){var o=(n+":"+r).replace(/'|\\/g,"_");return i.__exp=i.__exp||{},i.__exp[o]=i[n].text.replace(new RegExp("(^|[^\\w$])"+i[n].arg+"([^\\w$])","g"),"$1"+r+"$2"),t+"def.__exp['"+o+"']"}}));var n=new Function("def","return "+t)(i);return n?r(o,n,i):n})}(t,e,n||{}):e;c=("var out='"+(t.strip?c.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,""):c).replace(/'|\\/g,"\\$&").replace(t.interpolate||d,function(e,t){return i.start+s(t)+i.end}).replace(t.encode||d,function(e,t){return r=!0,i.startencode+s(t)+i.end}).replace(t.conditional||d,function(e,t,n){return t?n?"';}else if("+s(n)+"){out+='":"';}else{out+='":n?"';if("+s(n)+"){out+='":"';}out+='"}).replace(t.iterate||d,function(e,t,n,r){return t?(a+=1,o=r||"i"+a,t=s(t),"';var arr"+a+"="+t+";if(arr"+a+"){var "+n+","+o+"=-1,l"+a+"=arr"+a+".length-1;while("+o+"<l"+a+"){"+n+"=arr"+a+"["+o+"+=1];out+='"):"';} } out+='"}).replace(t.evaluate||d,function(e,t){return"';"+s(t)+"out+='"})+"';return out;").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r").replace(/(\s|;|\}|^|\{)out\+='';/g,"$1").replace(/\+''/g,""),r&&(t.selfcontained||!globalThis||globalThis._encodeHTML||(globalThis._encodeHTML=u.encodeHTMLSource(t.doNotSkipEncoded)),c="var encodeHTML = typeof _encodeHTML !== 'undefined' ? _encodeHTML : ("+u.encodeHTMLSource.toString()+"("+(t.doNotSkipEncoded||"")+"));"+c);try{return new Function(t.varname,c)}catch(e){throw"undefined"!=typeof console&&console.log("Could not create a template function: "+c),e}},u.compile=function(e,t){return u.template(e,null,t)}}();