All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.butterfaces-external.mustache.min.js Maven / Gradle / Ivy

The newest version!
!function(e,t){"object"==typeof exports&&exports?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.Mustache={})}(this,function(e){function t(e){return"function"==typeof e}function n(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function r(e,t){return d.call(e,t)}function i(e){return!r(v,e)}function o(e){return String(e).replace(/[&<>"'\/]/g,function(e){return g[e]})}function s(t,r){function o(){if(_&&!m)for(;g.length;)delete v[g.pop()];else g=[];_=!1,m=!1}function s(e){if("string"==typeof e&&(e=e.split(y,2)),!f(e)||2!==e.length)throw new Error("Invalid tags: "+e);p=new RegExp(n(e[0])+"\\s*"),l=new RegExp("\\s*"+n(e[1])),h=new RegExp("\\s*"+n("}"+e[1]))}if(!t)return[];var p,l,h,d=[],v=[],g=[],_=!1,m=!1;s(r||e.tags);for(var U,E,T,j,S,V,C=new c(t);!C.eos();){if(U=C.pos,T=C.scanUntil(p))for(var A=0,R=T.length;R>A;++A)j=T.charAt(A),i(j)?g.push(v.length):m=!0,v.push(["text",j,U,U+1]),U+=1,"\n"===j&&o();if(!C.scan(p))break;if(_=!0,E=C.scan(b)||"name",C.scan(w),"="===E?(T=C.scanUntil(k),C.scan(k),C.scanUntil(l)):"{"===E?(T=C.scanUntil(h),C.scan(x),C.scanUntil(l),E="&"):T=C.scanUntil(l),!C.scan(l))throw new Error("Unclosed tag at "+C.pos);if(S=[E,T,U,C.pos],v.push(S),"#"===E||"^"===E)d.push(S);else if("/"===E){if(V=d.pop(),!V)throw new Error('Unopened section "'+T+'" at '+U);if(V[1]!==T)throw new Error('Unclosed section "'+V[1]+'" at '+U)}else"name"===E||"{"===E||"&"===E?m=!0:"="===E&&s(T)}if(V=d.pop())throw new Error('Unclosed section "'+V[1]+'" at '+C.pos);return u(a(v))}function a(e){for(var t,n,r=[],i=0,o=e.length;o>i;++i)t=e[i],t&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(r.push(t),n=t));return r}function u(e){for(var t,n,r=[],i=r,o=[],s=0,a=e.length;a>s;++s)switch(t=e[s],t[0]){case"#":case"^":i.push(t),o.push(t),i=t[4]=[];break;case"/":n=o.pop(),n[5]=t[2],i=o.length>0?o[o.length-1][4]:r;break;default:i.push(t)}return r}function c(e){this.string=e,this.tail=e,this.pos=0}function p(e,t){this.view=null==e?{}:e,this.cache={".":this.view},this.parent=t}function l(){this.cache={}}var h=Object.prototype.toString,f=Array.isArray||function(e){return"[object Array]"===h.call(e)},d=RegExp.prototype.test,v=/\S/,g={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},w=/\s*/,y=/\s+/,k=/\s*=/,x=/\s*\}/,b=/#|\^|\/|>|\{|&|=|!/;c.prototype.eos=function(){return""===this.tail},c.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},c.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},p.prototype.push=function(e){return new p(e,this)},p.prototype.lookup=function(e){var n,r=this.cache;if(e in r)n=r[e];else{for(var i,o,s=this;s;){if(e.indexOf(".")>0)for(n=s.view,i=e.split("."),o=0;null!=n&&ou;++u)s=void 0,i=e[u],o=i[0],"#"===o?s=this._renderSection(i,t,n,r):"^"===o?s=this._renderInverted(i,t,n,r):">"===o?s=this._renderPartial(i,t,n,r):"&"===o?s=this._unescapedValue(i,t):"name"===o?s=this._escapedValue(i,t):"text"===o&&(s=this._rawValue(i)),void 0!==s&&(a+=s);return a},l.prototype._renderSection=function(e,n,r,i){function o(e){return s.render(e,n,r)}var s=this,a="",u=n.lookup(e[1]);if(u){if(f(u))for(var c=0,p=u.length;p>c;++c)a+=this.renderTokens(e[4],n.push(u[c]),r,i);else if("object"==typeof u||"string"==typeof u||"number"==typeof u)a+=this.renderTokens(e[4],n.push(u),r,i);else if(t(u)){if("string"!=typeof i)throw new Error("Cannot use higher-order sections without the original template");u=u.call(n.view,i.slice(e[3],e[5]),o),null!=u&&(a+=u)}else a+=this.renderTokens(e[4],n,r,i);return a}},l.prototype._renderInverted=function(e,t,n,r){var i=t.lookup(e[1]);return!i||f(i)&&0===i.length?this.renderTokens(e[4],t,n,r):void 0},l.prototype._renderPartial=function(e,n,r){if(r){var i=t(r)?r(e[1]):r[e[1]];return null!=i?this.renderTokens(this.parse(i),n,r,i):void 0}},l.prototype._unescapedValue=function(e,t){var n=t.lookup(e[1]);return null!=n?n:void 0},l.prototype._escapedValue=function(t,n){var r=n.lookup(t[1]);return null!=r?e.escape(r):void 0},l.prototype._rawValue=function(e){return e[1]},e.name="mustache.js",e.version="1.2.0",e.tags=["{{","}}"];var _=new l;e.clearCache=function(){return _.clearCache()},e.parse=function(e,t){return _.parse(e,t)},e.render=function(e,t,n){return _.render(e,t,n)},e.to_html=function(n,r,i,o){var s=e.render(n,r,i);return t(o)?void o(s):s},e.escape=o,e.Scanner=c,e.Context=p,e.Writer=l});




© 2015 - 2025 Weber Informatics LLC | Privacy Policy