le0pard/mongodb_logger

View on GitHub
app/assets/javascripts/vendors/mustache.min.js

Summary

Maintainability
A
0 mins
Test Coverage
(function(t,l){"object"===typeof exports&&exports?module.exports=l:"function"===typeof define&&define.amd?define(l):t.Mustache=l})(this,function(){function t(a){return a.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function l(a){this.tail=this.string=a;this.pos=0}function j(a,b){this.view=a;this.parent=b;this._cache={}}function m(){this.clearCache()}function r(a,b,c,f){for(var d="",g,e,l=0,j=a.length;l<j;++l)switch(g=a[l],e=g[1],g[0]){case "#":e=c.lookup(e);if("object"===typeof e)if(v(e))for(var n=
0,h=e.length;n<h;++n)d+=r(g[4],b,c.push(e[n]),f);else e&&(d+=r(g[4],b,c.push(e),f));else"function"===typeof e?(g=null==f?null:f.slice(g[3],g[5]),e=e.call(c.view,g,function(a){return b.render(a,c)}),null!=e&&(d+=e)):e&&(d+=r(g[4],b,c,f));break;case "^":e=c.lookup(e);if(!e||v(e)&&0===e.length)d+=r(g[4],b,c,f);break;case ">":e=b.getPartial(e);"function"===typeof e&&(d+=e(c));break;case "&":e=c.lookup(e);null!=e&&(d+=e);break;case "name":e=c.lookup(e);null!=e&&(d+=k.escape(e));break;case "text":d+=e}return d}
function w(a){return[RegExp(t(a[0])+"\\s*"),RegExp("\\s*"+t(a[1]))]}var k={name:"mustache.js",version:"0.7.2",tags:["{{","}}"]};k.Scanner=l;k.Context=j;k.Writer=m;var z=/\s*/,x=/\s+/,A=/\S/,y=/\s*=/,B=/\s*\}/,C=/#|\^|\/|>|\{|&|=|!/,D=RegExp.prototype.test,E=Object.prototype.toString,v=Array.isArray||function(a){return"[object Array]"===E.call(a)},F={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};k.escape=function(a){return String(a).replace(/[&<>"'\/]/g,function(a){return F[a]})};
l.prototype.eos=function(){return""===this.tail};l.prototype.scan=function(a){return(a=this.tail.match(a))&&0===a.index?(this.tail=this.tail.substring(a[0].length),this.pos+=a[0].length,a[0]):""};l.prototype.scanUntil=function(a){var b=this.tail.search(a);switch(b){case -1:a=this.tail;this.pos+=this.tail.length;this.tail="";break;case 0:a="";break;default:a=this.tail.substring(0,b),this.tail=this.tail.substring(b),this.pos+=b}return a};j.make=function(a){return a instanceof j?a:new j(a)};j.prototype.push=
function(a){return new j(a,this)};j.prototype.lookup=function(a){var b=this._cache[a];if(!b){if("."==a)b=this.view;else for(var c=this;c;){if(0<a.indexOf("."))for(var b=c.view,f=a.split("."),d=0;b&&d<f.length;)b=b[f[d++]];else b=c.view[a];if(null!=b)break;c=c.parent}this._cache[a]=b}"function"===typeof b&&(b=b.call(this.view));return b};m.prototype.clearCache=function(){this._cache={};this._partialCache={}};m.prototype.compile=function(a,b){var c=this._cache[a];c||(c=k.parse(a,b),c=this._cache[a]=
this.compileTokens(c,a));return c};m.prototype.compilePartial=function(a,b,c){b=this.compile(b,c);return this._partialCache[a]=b};m.prototype.getPartial=function(a){!(a in this._partialCache)&&this._loadPartial&&this.compilePartial(a,this._loadPartial(a));return this._partialCache[a]};m.prototype.compileTokens=function(a,b){var c=this;return function(f,d){if(d)if("function"===typeof d)c._loadPartial=d;else for(var g in d)c.compilePartial(g,d[g]);return r(a,c,j.make(f),b)}};m.prototype.render=function(a,
b,c){return this.compile(a)(b,c)};k.parse=function(a,b){a=a||"";b=b||k.tags;"string"===typeof b&&(b=b.split(x));if(2!==b.length)throw Error("Invalid tags: "+b.join(", "));for(var c=w(b),f=new l(a),d=[],g=[],e=[],j=!1,m=!1,n,h,p,s;!f.eos();){n=f.pos;if(p=f.scanUntil(c[0])){s=0;for(var r=p.length;s<r;++s)if(h=p.charAt(s),D.call(A,h)?m=!0:e.push(g.length),g.push(["text",h,n,n+1]),n+=1,"\n"==h){if(j&&!m)for(;e.length;)delete g[e.pop()];else e=[];m=j=!1}}if(!f.scan(c[0]))break;j=!0;h=f.scan(C)||"name";
f.scan(z);"="===h?(p=f.scanUntil(y),f.scan(y),f.scanUntil(c[1])):"{"===h?(p=f.scanUntil(RegExp("\\s*"+t("}"+b[1]))),f.scan(B),f.scanUntil(c[1]),h="&"):p=f.scanUntil(c[1]);if(!f.scan(c[1]))throw Error("Unclosed tag at "+f.pos);s=[h,p,n,f.pos];g.push(s);if("#"===h||"^"===h)d.push(s);else if("/"===h){if(0===d.length)throw Error('Unopened section "'+p+'" at '+n);h=d.pop();if(h[1]!==p)throw Error('Unclosed section "'+h[1]+'" at '+n);}else if("name"===h||"{"===h||"&"===h)m=!0;else if("="===h){b=p.split(x);
if(2!==b.length)throw Error("Invalid tags at "+n+": "+b.join(", "));c=w(b)}}if(h=d.pop())throw Error('Unclosed section "'+h[1]+'" at '+f.pos);for(var c=g,f=[],q,g=0,e=c.length;g<e;++g)if(d=c[g])"text"===d[0]&&q&&"text"===q[0]?(q[1]+=d[1],q[3]=d[3]):(q=d,f.push(d));q=f;f=c=[];d=[];e=0;for(j=q.length;e<j;++e)switch(g=q[e],g[0]){case "#":case "^":d.push(g);f.push(g);f=g[4]=[];break;case "/":d.pop()[5]=g[2];f=0<d.length?d[d.length-1][4]:c;break;default:f.push(g)}return c};var u=new m;k.clearCache=function(){return u.clearCache()};
k.compile=function(a,b){return u.compile(a,b)};k.compilePartial=function(a,b,c){return u.compilePartial(a,b,c)};k.compileTokens=function(a,b){return u.compileTokens(a,b)};k.render=function(a,b,c){return u.render(a,b,c)};k.to_html=function(a,b,c,f){a=k.render(a,b,c);if("function"===typeof f)f(a);else return a};return k}());