// oj.mustache.min.js v0.7.2 | Copyright 2013 Evan Moran | ojjs.org/license
(function(e,t){var n=t;plugin=function(e,t){return typeof t!="object"&&(t={}),{mustache:function(){var t,r,i,s;t=e.unionArguments(arguments),json=t.options,s=t.args;if(s.length==0)throw new Error("oj.mustache: template string not found");if(Object.keys(json).length==0)throw new Error("oj.mustache: json object not found");return r=s.join(""),e.emit(n.to_html(r,json))}}},typeof oj!="undefined"&&oj.use(plugin),typeof exports=="object"&&exports?module.exports=plugin:typeof define=="function"&&define.amd?define(plugin):e.Mustache=n})(this,function(){function u(e,t){return RegExp.prototype.test.call(e,t)}function a(e){return!u(r,e)}function l(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function h(e){return String(e).replace(/[&<>"'\/]/g,function(e){return c[e]})}function p(e){this.string=e,this.tail=e,this.pos=0}function d(e,t){this.view=e,this.parent=t,this.clearCache()}function v(){this.clearCache()}function m(e){function n(e,n,r){if(!t[e]){var i=m(n);t[e]=function(e,t){return i(e,t,r)}}return t[e]}var t={};return function(t,r,i){var s="",o,u;for(var a=0,f=e.length;a<f;++a){o=e[a];switch(o[0]){case"#":u=i.slice(o[3],o[5]),s+=t._section(o[1],r,u,n(a,o[4],i));break;case"^":s+=t._inverted(o[1],r,n(a,o[4],i));break;case">":s+=t._partial(o[1],r);break;case"&":s+=t._name(o[1],r);break;case"name":s+=t._escaped(o[1],r);break;case"text":s+=o[1]}}return s}}function g(e){var t=[],n=t,r=[],i;for(var s=0,o=e.length;s<o;++s){i=e[s];switch(i[0]){case"#":case"^":r.push(i),n.push(i),n=i[4]=[];break;case"/":var u=r.pop();u[5]=i[2],n=r.length>0?r[r.length-1][4]:t;break;default:n.push(i)}}return t}function y(e){var t=[],n,r;for(var i=0,s=e.length;i<s;++i)n=e[i],n[0]==="text"&&r&&r[0]==="text"?(r[1]+=n[1],r[3]=n[3]):(r=n,t.push(n));return t}function b(e){return[new RegExp(l(e[0])+"\\s*"),new RegExp("\\s*"+l(e[1]))]}var e={};e.name="mustache.js",e.version="0.7.2",e.tags=["{{","}}"],e.Scanner=p,e.Context=d,e.Writer=v;var t=/\s*/,n=/\s+/,r=/\S/,i=/\s*=/,s=/\s*\}/,o=/#|\^|\/|>|\{|&|=|!/,f=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},c={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};e.escape=h,p.prototype.eos=function(){return this.tail===""},p.prototype.scan=function(e){var t=this.tail.match(e);return t&&t.index===0?(this.tail=this.tail.substring(t[0].length),this.pos+=t[0].length,t[0]):""},p.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.pos+=this.tail.length,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n),this.pos+=n}return t},d.make=function(e){return e instanceof d?e:new d(e)},d.prototype.clearCache=function(){this._cache={}},d.prototype.push=function(e){return new d(e,this)},d.prototype.lookup=function(e){var t=this._cache[e];if(!t){if(e===".")t=this.view;else{var n=this;while(n){if(e.indexOf(".")>0){var r=e.split("."),i=0;t=n.view;while(t&&i<r.length)t=t[r[i++]]}else t=n.view[e];if(t!=null)break;n=n.parent}}this._cache[e]=t}return typeof t=="function"&&(t=t.call(this.view)),t},v.prototype.clearCache=function(){this._cache={},this._partialCache={}},v.prototype.compile=function(t,n){var r=this._cache[t];if(!r){var i=e.parse(t,n);r=this._cache[t]=this.compileTokens(i,t)}return r},v.prototype.compilePartial=function(e,t,n){var r=this.compile(t,n);return this._partialCache[e]=r,r},v.prototype.compileTokens=function(e,t){var n=m(e),r=this;return function(e,i){if(i)if(typeof i=="function")r._loadPartial=i;else for(var s in i)r.compilePartial(s,i[s]);return n(r,d.make(e),t)}},v.prototype.render=function(e,t,n){return this.compile(e)(t,n)},v.prototype._section=function(e,t,n,r){var i=t.lookup(e);switch(typeof i){case"object":if(f(i)){var s="";for(var o=0,u=i.length;o<u;++o)s+=r(this,t.push(i[o]));return s}return i?r(this,t.push(i)):"";case"function":var a=this,l=function(e){return a.render(e,t)},c=i.call(t.view,n,l);return c!=null?c:"";default:if(i)return r(this,t)}return""},v.prototype._inverted=function(e,t,n){var r=t.lookup(e);return!r||f(r)&&r.length===0?n(this,t):""},v.prototype._partial=function(e,t){!(e in this._partialCache)&&this._loadPartial&&this.compilePartial(e,this._loadPartial(e));var n=this._partialCache[e];return n?n(t):""},v.prototype._name=function(e,t){var n=t.lookup(e);return typeof n=="function"&&(n=n.call(t.view)),n==null?"":String(n)},v.prototype._escaped=function(t,n){return e.escape(this._name(t,n))},e.parse=function(r,u){function E(){if(m&&!w)while(v.length)d.splice(v.pop(),1);else v=[];m=!1,w=!1}r=r||"",u=u||e.tags,typeof u=="string"&&(u=u.split(n));if(u.length!==2)throw new Error("Invalid tags: "+u.join(", "));var f=b(u),c=new p(r),h=[],d=[],v=[],m=!1,w=!1,S,x,T,N;while(!c.eos()){S=c.pos,T=c.scanUntil(f[0]);if(T)for(var C=0,k=T.length;C<k;++C)N=T.charAt(C),a(N)?v.push(d.length):w=!0,d.push(["text",N,S,S+1]),S+=1,N==="\n"&&E();S=c.pos;if(!c.scan(f[0]))break;m=!0,x=c.scan(o)||"name",c.scan(t);if(x==="=")T=c.scanUntil(i),c.scan(i),c.scanUntil(f[1]);else if(x==="{"){var L=new RegExp("\\s*"+l("}"+u[1]));T=c.scanUntil(L),c.scan(s),c.scanUntil(f[1]),x="&"}else T=c.scanUntil(f[1]);if(!c.scan(f[1]))throw new Error("Unclosed tag at "+c.pos);if(x==="/"){if(h.length===0)throw new Error('Unopened section "'+T+'" at '+S);var A=h.pop();if(A[1]!==T)throw new Error('Unclosed section "'+A[1]+'" at '+S)}var O=[x,T,S,c.pos];d.push(O);if(x==="#"||x==="^")h.push(O);else if(x==="name"||x==="{"||x==="&")w=!0;else if(x==="="){u=T.split(n);if(u.length!==2)throw new Error("Invalid tags at "+S+": "+u.join(", "));f=b(u)}}var A=h.pop();if(A)throw new Error('Unclosed section "'+A[1]+'" at '+c.pos);return g(y(d))};var w=new v;return e.clearCache=function(){return w.clearCache()},e.compile=function(e,t){return w.compile(e,t)},e.compilePartial=function(e,t,n){return w.compilePartial(e,t,n)},e.compileTokens=function(e,t){return w.compileTokens(e,t)},e.render=function(e,t,n){return w.render(e,t,n)},e.to_html=function(t,n,r,i){var s=e.render(t,n,r);if(typeof i!="function")return s;i(s)},e}())
