New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

twig

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twig - npm Package Compare versions

Comparing version 0.4.5 to 0.4.6

docs/twig.compiler.html

2

package.json

@@ -5,3 +5,3 @@ {

"description": "JS port of the Twig templating language.",
"version": "0.4.5",
"version": "0.4.6",
"homepage": "https://github.com/justjohn/twig.js",

@@ -8,0 +8,0 @@ "licenses": [

@@ -13,2 +13,4 @@ [![Build Status](https://secure.travis-ci.org/justjohn/twig.js.png)](http://travis-ci.org/#!/justjohn/twig.js)

### Docs
Documentation is available in the [twig.js wiki](https://github.com/justjohn/twig.js/wiki) on Github.

@@ -18,3 +20,3 @@

For a list of supported tags/filters/functions/tests see the [implementation notes on the wiki](https://github.com/justjohn/twig.js/wiki/Supported-Features---Implementation-Notes).
For a list of supported tags/filters/functions/tests see the [Implementation Notes](https://github.com/justjohn/twig.js/wiki/Implementation-Notes) page on the wiki.

@@ -21,0 +23,0 @@ # Node Usage

var twig = require("./twig").twig;
var output = twig({
data: "{% if a.hasWidget('has') and a.getWidget('get').first.second %} Yes {% else %} No {% endif %}"
data: "{% set outerloop = [1, 1, 1, 1] %}{% set value = 'b' %}{% set known_values = [{val: 'a'}, {val: 'b'}, {val: 'c'}] %}{% for _ in outerloop %} {% for known in known_values if known.val == value %} match! {% else %} no match! {% endfor %}{% endfor %}"
// data: "{{ c.a() and d.a().b.x }}"
}).render({
a: {
hasWidget: function() { return true },
getWidget: function() { return { first: { second: true } } }
},
c: {
a: function() { return { b:"Yes" } }
},
d: {
a: function() { return { b: "No" } }
}
});
}).render();
console.log(output);

@@ -5,3 +5,3 @@ // Twig.js

// https://github.com/justjohn/twig.js
var Twig=function(a){function b(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return b!==undefined&&b!==null&&c===a}function c(b,c){var d,e,f="/",g=[],h;if(b.url)d=b.url;else{if(!b.path)throw new a.Error("Cannot extend an inline template.");d=b.path}e=d.split(f),e.pop(),e=e.concat(c.split(f));while(e.length>0)h=e.shift(),h!="."&&(h==".."&&g.length>0&&g[g.length-1]!=".."?g.pop():g.push(h));return g.join(f)}return"use strict",a.trace=!1,a.debug=!1,a.cache=!0,a.placeholders={parent:"{{|PARENT|}}"},a.Error=function(a){this.message=a,this.name="TwigException",this.type="TwigException"},a.Error.prototype.toString=function(){return this.name+": "+this.message},a.log={trace:function(){a.trace&&console&&console.log(Array.prototype.slice.call(arguments))},debug:function(){a.debug&&console&&console.log(Array.prototype.slice.call(arguments))}},a.token={},a.token.type={output:"output",logic:"logic",comment:"comment",raw:"raw"},a.token.definitions={output:{type:a.token.type.output,open:"{{",close:"}}"},logic:{type:a.token.type.logic,open:"{%",close:"%}"},comment:{type:a.token.type.comment,open:"{#",close:"#}"}},a.token.strings=['"',"'"],a.token.findStart=function(b){var c={position:null,def:null},d,e,f;for(d in a.token.definitions)a.token.definitions.hasOwnProperty(d)&&(e=a.token.definitions[d],f=b.indexOf(e.open),a.log.trace("Twig.token.findStart: ","Searching for ",e.open," found at ",f),f>=0&&(c.position===null||f<c.position)&&(c.position=f,c.def=e));return c},a.token.findEnd=function(b,c,d){var e=null,f=!1,g=0,h=null,i=null,j=null,k=null,l=null,m=null,n,o;while(!f){h=null,i=null,j=b.indexOf(c.close,g);if(!(j>=0))throw new a.Error("Unable to find closing bracket '"+c.close+"'"+" opened near template position "+d);e=j,f=!0,o=a.token.strings.length;for(n=0;n<o;n+=1)l=b.indexOf(a.token.strings[n],g),l>0&&l<j&&(h===null||l<h)&&(h=l,i=a.token.strings[n]);if(h!==null){k=h+1,e=null,f=!1;for(;;){m=b.indexOf(i,k);if(m<0)throw"Unclosed string in template";if(b.substr(m-1,1)!=="\\"){g=m+1;break}k=m+1}}}return e},a.tokenize=function(b){var c=[],d=0,e=null,f=null;while(b.length>0)e=a.token.findStart(b),a.log.trace("Twig.tokenize: ","Found token: ",e),e.position!==null?(e.position>0&&c.push({type:a.token.type.raw,value:b.substring(0,e.position)}),b=b.substr(e.position+e.def.open.length),d+=e.position+e.def.open.length,f=a.token.findEnd(b,e.def,d),a.log.trace("Twig.tokenize: ","Token ends at ",f),c.push({type:e.def.type,value:b.substring(0,f).trim()}),b=b.substr(f+e.def.close.length),d+=f+e.def.close.length):(c.push({type:a.token.type.raw,value:b}),b="");return c},a.compile=function(b){var c=[],d=[],e=[],f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=null;while(b.length>0){f=b.shift(),a.log.trace("Compiling token ",f);switch(f.type){case a.token.type.raw:d.length>0?e.push(f):c.push(f);break;case a.token.type.logic:g=a.logic.compile.apply(this,[f]),l=g.type,m=a.logic.handler[l].open,n=a.logic.handler[l].next,a.log.trace("Twig.compile: ","Compiled logic token to ",g," next is: ",n," open is : ",m);if(m!==undefined&&!m){i=d.pop(),j=a.logic.handler[i.type];if(j.next.indexOf(l)<0)throw new Error(l+" not expected after a "+i.type);i.output=i.output||[],i.output=i.output.concat(e),e=[],k={type:a.token.type.logic,token:i},d.length>0?e.push(k):c.push(k)}n!==undefined&&n.length>0?(a.log.trace("Twig.compile: ","Pushing ",g," to logic stack."),d.length>0&&(i=d.pop(),i.output=i.output||[],i.output=i.output.concat(e),d.push(i),e=[]),d.push(g)):m!==undefined&&m&&(k={type:a.token.type.logic,token:g},d.length>0?e.push(k):c.push(k));break;case a.token.type.comment:break;case a.token.type.output:a.expression.compile.apply(this,[f]),d.length>0?e.push(f):c.push(f)}a.log.trace("Twig.compile: "," Output: ",c," Logic Stack: ",d," Pending Output: ",e)}if(d.length>0)throw h=d.pop(),new Error("Unable to find an end tag for "+h.type+", expecting one of "+h.next);return c},a.parse=function(b,c){var d=[],e=!0,f=this;return c=c||{},b.forEach(function(b){a.log.debug("Twig.parse: ","Parsing token: ",b);switch(b.type){case a.token.type.raw:d.push(b.value);break;case a.token.type.logic:var g=b.token,h=a.logic.parse.apply(f,[g,c,e]);h.chain!==undefined&&(e=h.chain),h.context!==undefined&&(c=h.context),h.output!==undefined&&d.push(h.output);break;case a.token.type.comment:break;case a.token.type.output:d.push(a.expression.parse.apply(f,[b.stack,c]))}}),d.join("")},a.prepare=function(b){var c,d;return a.log.debug("Twig.prepare: ","Tokenizing ",b),d=a.tokenize.apply(this,[b]),a.log.debug("Twig.prepare: ","Compiling ",d),c=a.compile.apply(this,[d]),a.log.debug("Twig.prepare: ","Compiled ",c),c},a.Templates={registry:{}},a.validateId=function(b){if(b==="prototype")throw new a.Error(b+" is not a valid twig identifier");if(a.Templates.registry.hasOwnProperty(b))throw new a.Error("There is already a template with the ID "+b);return!0},a.Templates.save=function(b){if(b.id===undefined)throw new a.Error("Unable to save template with no id");a.Templates.registry[b.id]=b},a.Templates.load=function(b){return a.Templates.registry.hasOwnProperty(b)?a.Templates.registry[b]:null},a.Templates.loadRemote=function(b,c,d,e){var f=c.id,g=c.method,h=c.async,i=c.precompiled,j=c.options,k=null;h===undefined&&(h=!0),f===undefined&&(f=b);if(a.cache&&a.Templates.registry.hasOwnProperty(f))return d&&d(a.Templates.registry[f]),a.Templates.registry[f];if(g=="ajax"){if(typeof XMLHttpRequest=="undefined")throw new Error("Unsupported platform: Unable to do remote requests because there is no XMLHTTPRequest implementation");var l=new XMLHttpRequest;l.onreadystatechange=function(){var c=null;l.readyState==4&&(a.log.debug("Got template ",l.responseText),i===!0?c=JSON.parse(l.responseText):c=l.responseText,k=new a.Template({data:c,id:f,url:b,options:j}),d&&d(k))},l.open("GET",b,h),l.send()}else(function(){var c=require("fs"),g=null;h===!0?c.readFile(b,"utf8",function(c,g){if(c){e&&e(c);return}i===!0&&(g=JSON.parse(g)),k=new a.Template({data:g,id:f,path:b,options:j}),d&&d(k)}):(g=c.readFileSync(b,"utf8"),i===!0&&(g=JSON.parse(g)),k=new a.Template({data:g,id:f,path:b,options:j}),d&&d(k))})();return h===!1?k:!0},a.Template=function(d){var e=d.data,f=d.id,g=d.blocks,h=d.path,i=d.url,j=d.options;this.id=f,this.path=h,this.url=i,this.options=j,this.reset=function(){a.log.debug("Twig.Template.reset","Reseting template "+this.id),this.blocks={},this.child={blocks:g||{}},this.extend=null},this.reset(),b("String",e)?this.tokens=a.prepare.apply(this,[e]):this.tokens=e,this.render=function(b,d){d=d||{};var e=this,f,g=d.output=="blocks";return this.context=b,this.reset(),d.blocks&&(this.blocks=d.blocks),this.importFile=function(b){var d=c(e,b),f=a.Templates.loadRemote(d,{method:e.url?"ajax":"fs",async:!1,id:d});return f},this.importBlocks=function(a,c){var d=this.importFile(a),f;c=c||!1,d.render(b),Object.keys(d.blocks).forEach(function(a){if(c||e.blocks[a]===undefined)e.blocks[a]=d.blocks[a]})},f=a.parse.apply(this,[this.tokens,b]),this.extend?(i=c(this,this.extend),this.parent=a.Templates.loadRemote(i,{method:this.url?"ajax":"fs",async:!1,id:i}),this.parent.render(b,{blocks:this.blocks})):g===!0?this.blocks:f},this.compile=function(b){return a.compiler.compile(this,b)},f!==undefined&&a.Templates.save(this)},a}(Twig||{});(function(){"use strict",String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){if(this===void 0||this===null)throw new TypeError;var b=Object(this),c=b.length>>>0;if(c===0)return-1;var d=0;arguments.length>0&&(d=Number(arguments[1]),d!==d?d=0:d!==0&&d!==Infinity&&d!==-Infinity&&(d=(d>0||-1)*Math.floor(Math.abs(d))));if(d>=c)return-1;var e=d>=0?d:Math.max(c-Math.abs(d),0);for(;e<c;e++)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c,d;if(this==null)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if({}.toString.call(a)!="[object Function]")throw new TypeError(a+" is not a function");b&&(c=b),d=0;while(d<f){var g;d in e&&(g=e[d],a.call(c,g,d,e)),d++}}),Object.keys||(Object.keys=function(a){if(a!==Object(a))throw new TypeError("Object.keys called on non-object");var b=[],c;for(c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b})})();var Twig=function(a){a.lib={};var b=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function c(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")}var d=function(){return d.cache.hasOwnProperty(arguments[0])||(d.cache[arguments[0]]=d.parse(arguments[0])),d.format.call(null,d.cache[arguments[0]],arguments)};return d.format=function(d,e){var f=1,g=d.length,h="",i,j=[],k,l,m,n,o,p;for(k=0;k<g;k++){h=a(d[k]);if(h==="string")j.push(d[k]);else if(h==="array"){m=d[k];if(m[2]){i=e[f];for(l=0;l<m[2].length;l++){if(!i.hasOwnProperty(m[2][l]))throw b('[sprintf] property "%s" does not exist',m[2][l]);i=i[m[2][l]]}}else m[1]?i=e[m[1]]:i=e[f++];if(/[^s]/.test(m[8])&&a(i)!="number")throw b("[sprintf] expecting number but found %s",a(i));switch(m[8]){case"b":i=i.toString(2);break;case"c":i=String.fromCharCode(i);break;case"d":i=parseInt(i,10);break;case"e":i=m[7]?i.toExponential(m[7]):i.toExponential();break;case"f":i=m[7]?parseFloat(i).toFixed(m[7]):parseFloat(i);break;case"o":i=i.toString(8);break;case"s":i=(i=String(i))&&m[7]?i.substring(0,m[7]):i;break;case"u":i=Math.abs(i);break;case"x":i=i.toString(16);break;case"X":i=i.toString(16).toUpperCase()}i=/[def]/.test(m[8])&&m[3]&&i>=0?"+"+i:i,o=m[4]?m[4]=="0"?"0":m[4].charAt(1):" ",p=m[6]-String(i).length,n=m[6]?c(o,p):"",j.push(m[5]?i+n:n+i)}}return j.join("")},d.cache={},d.parse=function(a){var b=a,c=[],d=[],e=0;while(b){if((c=/^[^\x25]+/.exec(b))!==null)d.push(c[0]);else if((c=/^\x25{2}/.exec(b))!==null)d.push("%");else{if((c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b))===null)throw"[sprintf] huh?";if(c[2]){e|=1;var f=[],g=c[2],h=[];if((h=/^([a-z_][a-z_\d]*)/i.exec(g))===null)throw"[sprintf] huh?";f.push(h[1]);while((g=g.substring(h[0].length))!=="")if((h=/^\.([a-z_][a-z_\d]*)/i.exec(g))!==null)f.push(h[1]);else{if((h=/^\[(\d+)\]/.exec(g))===null)throw"[sprintf] huh?";f.push(h[1])}c[2]=f}else e|=2;if(e===3)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";d.push(c)}b=b.substring(c[0].length)}return d},d}(),c=function(a,c){return c.unshift(a),b.apply(null,c)};return a.lib.sprintf=b,a.lib.vsprintf=c,function(){function f(a){return(a=Math.abs(a)%100)%10==1&&a!=11?"st":a%10==2&&a!=12?"nd":a%10==3&&a!=13?"rd":"th"}function g(a){var b=new Date(a.getFullYear()+1,0,4);return(b-a)/864e5<7&&(a.getDay()+6)%7<(b.getDay()+6)%7?b.getFullYear():a.getMonth()>0||a.getDate()>=4?a.getFullYear():a.getFullYear()-((a.getDay()+6)%7-a.getDate()>2?1:0)}function h(a){var b=new Date(g(a),0,4);return b.setDate(b.getDate()-(b.getDay()+6)%7),parseInt((a-b)/6048e5)+1}var b="Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(","),c="Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),d="Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),e="January,February,March,April,May,June,July,August,September,October,November,December".split(",");a.lib.formatDate=function(a,i){if(typeof i!="string"||/^\s*$/.test(i))return a+"";var j=new Date(a.getFullYear(),0,1),k=a;return i.replace(/[dDjlNSwzWFmMntLoYyaABgGhHisu]/g,function(a){switch(a){case"d":return("0"+k.getDate()).replace(/^.+(..)$/,"$1");case"D":return b[k.getDay()];case"j":return k.getDate();case"l":return c[k.getDay()];case"N":return(k.getDay()+6)%7+1;case"S":return f(k.getDate());case"w":return k.getDay();case"z":return Math.ceil((j-k)/864e5);case"W":return("0"+h(k)).replace(/^.(..)$/,"$1");case"F":return e[k.getMonth()];case"m":return("0"+(k.getMonth()+1)).replace(/^.+(..)$/,"$1");case"M":return d[k.getMonth()];case"n":return k.getMonth()+1;case"t":return(new Date(k.getFullYear(),k.getMonth()+1,-1)).getDate();case"L":return(new Date(k.getFullYear(),1,29)).getDate()==29?1:0;case"o":return g(k);case"Y":return k.getFullYear();case"y":return(k.getFullYear()+"").replace(/^.+(..)$/,"$1");case"a":return k.getHours()<12?"am":"pm";case"A":return k.getHours()<12?"AM":"PM";case"B":return Math.floor(((k.getUTCHours()+1)%24+k.getUTCMinutes()/60+k.getUTCSeconds()/3600)*1e3/24);case"g":return k.getHours()%12!=0?k.getHours()%12:12;case"G":return k.getHours();case"h":return("0"+(k.getHours()%12!=0?k.getHours()%12:12)).replace(/^.+(..)$/,"$1");case"H":return("0"+k.getHours()).replace(/^.+(..)$/,"$1");case"i":return("0"+k.getMinutes()).replace(/^.+(..)$/,"$1");case"s":return("0"+k.getSeconds()).replace(/^.+(..)$/,"$1");case"u":return k.getMilliseconds()}})}}(),a.lib.strip_tags=function(a,b){b=(((b||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join("");var c=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,d=/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;return a.replace(d,"").replace(c,function(a,c){return b.indexOf("<"+c.toLowerCase()+">")>-1?a:""})},a.lib.strtotime=function(a,b){var c,d,e,f,g="";a=a.replace(/\s{2,}|^\s|\s$/g," "),a=a.replace(/[\t\r\n]/g,"");if(a==="now")return b===null||isNaN(b)?(new Date).getTime()/1e3|0:b|0;if(!isNaN(g=Date.parse(a)))return g/1e3|0;b?b=new Date(b*1e3):b=new Date,a=a.toLowerCase();var h={day:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6},mon:["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]},i=function(a){var c=a[2]&&a[2]==="ago",d=(d=a[0]==="last"?-1:1)*(c?-1:1);switch(a[0]){case"last":case"next":switch(a[1].substring(0,3)){case"yea":b.setFullYear(b.getFullYear()+d);break;case"wee":b.setDate(b.getDate()+d*7);break;case"day":b.setDate(b.getDate()+d);break;case"hou":b.setHours(b.getHours()+d);break;case"min":b.setMinutes(b.getMinutes()+d);break;case"sec":b.setSeconds(b.getSeconds()+d);break;case"mon":if(a[1]==="month"){b.setMonth(b.getMonth()+d);break};default:var e=h.day[a[1].substring(0,3)];if(typeof e!="undefined"){var f=e-b.getDay();f===0?f=7*d:f>0?a[0]==="last"&&(f-=7):a[0]==="next"&&(f+=7),b.setDate(b.getDate()+f),b.setHours(0,0,0,0)}}break;default:if(!/\d+/.test(a[0]))return!1;d*=parseInt(a[0],10);switch(a[1].substring(0,3)){case"yea":b.setFullYear(b.getFullYear()+d);break;case"mon":b.setMonth(b.getMonth()+d);break;case"wee":b.setDate(b.getDate()+d*7);break;case"day":b.setDate(b.getDate()+d);break;case"hou":b.setHours(b.getHours()+d);break;case"min":b.setMinutes(b.getMinutes()+d);break;case"sec":b.setSeconds(b.getSeconds()+d)}}return!0};e=a.match(/^(\d{2,4}-\d{2}-\d{2})(?:\s(\d{1,2}:\d{2}(:\d{2})?)?(?:\.(\d+))?)?$/);if(e!==null)return e[2]?e[3]||(e[2]+=":00"):e[2]="00:00:00",f=e[1].split(/-/g),f[1]=h.mon[f[1]-1]||f[1],f[0]=+f[0],f[0]=f[0]>=0&&f[0]<=69?"20"+(f[0]<10?"0"+f[0]:f[0]+""):f[0]>=70&&f[0]<=99?"19"+f[0]:f[0]+"",parseInt(this.strtotime(f[2]+" "+f[1]+" "+f[0]+" "+e[2])+(e[4]?e[4]/1e3:""),10);var j="([+-]?\\d+\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday)|(last|next)\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday))(\\sago)?";e=a.match(new RegExp(j,"gi"));if(e===null)return!1;for(c=0,d=e.length;c<d;c++)if(!i(e[c].split(" ")))return!1;return b.getTime()/1e3|0},a.lib.is=function(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return b!==undefined&&b!==null&&c===a},a}(Twig||{}),Twig=function(a){"use strict",a.logic={},a.logic.type={if_:"Twig.logic.type.if",endif:"Twig.logic.type.endif",for_:"Twig.logic.type.for",endfor:"Twig.logic.type.endfor",else_:"Twig.logic.type.else",elseif:"Twig.logic.type.elseif",set:"Twig.logic.type.set",filter:"Twig.logic.type.filter",endfilter:"Twig.logic.type.endfilter",block:"Twig.logic.type.block",endblock:"Twig.logic.type.endblock",extends_:"Twig.logic.type.extends",use:"Twig.logic.type.use",include:"Twig.logic.type.include"},a.logic.definitions=[{type:a.logic.type.if_,regex:/^if\s+([^\s].+)$/,next:[a.logic.type.else_,a.logic.type.elseif,a.logic.type.endif],open:!0,compile:function(b){var c=b.match[1];return b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:c}]).stack,delete b.match,b},parse:function(b,c,d){var e="",f=a.expression.parse.apply(this,[b.stack,c]);return d=!0,f&&(d=!1,e=a.parse.apply(this,[b.output,c])),{chain:d,output:e}}},{type:a.logic.type.elseif,regex:/^elseif\s+([^\s].*)$/,next:[a.logic.type.else_,a.logic.type.elseif,a.logic.type.endif],open:!1,compile:function(b){var c=b.match[1];return b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:c}]).stack,delete b.match,b},parse:function(b,c,d){var e="";return d&&a.expression.parse.apply(this,[b.stack,c])===!0&&(d=!1,e=a.parse.apply(this,[b.output,c])),{chain:d,output:e}}},{type:a.logic.type.else_,regex:/^else$/,next:[a.logic.type.endif,a.logic.type.endfor],open:!1,parse:function(b,c,d){var e="";return d&&(e=a.parse.apply(this,[b.output,c])),{chain:d,output:e}}},{type:a.logic.type.endif,regex:/^endif$/,next:[],open:!1},{type:a.logic.type.for_,regex:/^for\s+([a-zA-Z0-9_,\s]+)\s+in\s+([^\s].+)$/,next:[a.logic.type.else_,a.logic.type.endfor],open:!0,compile:function(b){var c=b.match[1],d=b.match[2],e=null,f=null;b.key_var=null,b.value_var=null;if(c.indexOf(",")>=0){e=c.split(",");if(e.length!==2)throw new a.Error("Invalid expression in for loop: "+c);b.key_var=e[0].trim(),b.value_var=e[1].trim()}else b.value_var=c;return f=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:d}]).stack,b.expression=f,delete b.match,b},parse:function(b,c,d){var e=a.expression.parse.apply(this,[b.expression,c]),f=[],g,h,i=0,j,k=this;return e instanceof Array?(h=e.length,e.forEach(function(d){c[b.value_var]=d,b.key_var&&(c[b.key_var]=i),c.loop={index:i+1,index0:i,revindex:h-i,revindex0:h-i-1,first:i===0,last:i===h-1,length:h,parent:c},f.push(a.parse.apply(k,[b.output,c])),i+=1})):e instanceof Object&&(e._keys!==undefined?j=e._keys:j=Object.keys(e),h=j.length,j.forEach(function(d){if(d==="_keys")return;c.loop={index:i+1,index0:i,revindex:h-i,revindex0:h-i-1,first:i===0,last:i===h-1,length:h,parent:c},c[b.value_var]=e[d],b.key_var&&(c[b.key_var]=d),f.push(a.parse.apply(k,[b.output,c])),i+=1})),d=f.length===0,{chain:d,output:f.join("")}}},{type:a.logic.type.endfor,regex:/^endfor$/,next:[],open:!1},{type:a.logic.type.set,regex:/^set\s+([a-zA-Z0-9_,\s]+)\s*=\s*(.+)$/,next:[],open:!0,compile:function(b){var c=b.match[1].trim(),d=b.match[2],e=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:d}]).stack;return b.key=c,b.expression=e,delete b.match,b},parse:function(b,c,d){var e=a.expression.parse.apply(this,[b.expression,c]),f=b.key;return c[f]=e,{chain:d,context:c}}},{type:a.logic.type.filter,regex:/^filter\s+(.+)$/,next:[a.logic.type.endfilter],open:!0,compile:function(b){var c="|"+b.match[1].trim();return b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:c}]).stack,delete b.match,b},parse:function(b,c,d){var e=a.parse.apply(this,[b.output,c]),f=[{type:a.expression.type.string,value:e}].concat(b.stack),g=a.expression.parse.apply(this,[f,c]);return{chain:d,output:g}}},{type:a.logic.type.endfilter,regex:/^endfilter$/,next:[],open:!1},{type:a.logic.type.block,regex:/^block\s+([a-zA-Z0-9_]+)$/,next:[a.logic.type.endblock],open:!0,compile:function(a){return a.block=a.match[1].trim(),delete a.match,a},parse:function(b,c,d){var e="",f="",g=this.blocks[b.block]&&this.blocks[b.block].indexOf(a.placeholders.parent)>-1;if(this.blocks[b.block]===undefined||g)e=a.expression.parse.apply(this,[{type:a.expression.type.string,value:a.parse.apply(this,[b.output,c])},c]),g?this.blocks[b.block]=this.blocks[b.block].replace(a.placeholders.parent,e):this.blocks[b.block]=e;return this.extend===null&&(this.child.blocks[b.block]?f=this.child.blocks[b.block]:f=this.blocks[b.block]),{chain:d,output:f}}},{type:a.logic.type.endblock,regex:/^endblock$/,next:[],open:!1},{type:a.logic.type.extends_,regex:/^extends\s+(.+)$/,next:[],open:!0,compile:function(b){var c=b.match[1].trim();return delete b.match,b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:c}]).stack,b},parse:function(b,c,d){var e=a.expression.parse.apply(this,[b.stack,c]);return this.extend=e,{chain:d,output:""}}},{type:a.logic.type.use,regex:/^use\s+(.+)$/,next:[],open:!0,compile:function(b){var c=b.match[1].trim();return delete b.match,b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:c}]).stack,b},parse:function(b,c,d){var e=a.expression.parse.apply(this,[b.stack,c]);return this.importBlocks(e),{chain:d,output:""}}},{type:a.logic.type.include,regex:/^include\s+(ignore missing\s+)?(.+?)\s*(?:with\s+(.+?))?\s*(only)?$/,next:[],open:!0,compile:function(b){var c=b.match,d=c[1]!==undefined,e=c[2].trim(),f=c[3],g=c[4]!==undefined;return delete b.match,b.only=g,b.includeMissing=d,b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:e}]).stack,f!==undefined&&(b.withStack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:f.trim()}]).stack),b},parse:function(b,c,d){var e={},f,g,h;if(!b.only)for(g in c)c.hasOwnProperty(g)&&(e[g]=c[g]);if(b.withStack!==undefined){f=a.expression.parse.apply(this,[b.withStack,c]);for(g in f)f.hasOwnProperty(g)&&(e[g]=f[g])}var i=a.expression.parse.apply(this,[b.stack,e]);return h=this.importFile(i),{chain:d,output:h.render(e)}}}],a.logic.handler={},a.logic.extendType=function(b,c){c=c||"Twig.logic.type"+b,a.logic.type[b]=c},a.logic.extend=function(b){if(!b.type)throw new a.Error("Unable to extend logic definition. No type provided for "+b);if(a.logic.type[b.type])throw new a.Error("Unable to extend logic definitions. Type "+b.type+" is already defined.");a.logic.extendType(b.type),a.logic.handler[b.type]=b};while(a.logic.definitions.length>0)a.logic.extend(a.logic.definitions.shift());return a.logic.compile=function(b){var c=b.value.trim(),d=a.logic.tokenize.apply(this,[c]),e=a.logic.handler[d.type];return e.compile&&(d=e.compile.apply(this,[d]),a.log.trace("Twig.logic.compile: ","Compiled logic token to ",d)),d},a.logic.tokenize=function(b){var c={},d=null,e=null,f=null,g=null,h=null,i=null;b=b.trim();for(d in a.logic.handler)if(a.logic.handler.hasOwnProperty(d)){e=a.logic.handler[d].type,f=a.logic.handler[d].regex,g=[],f instanceof Array?g=f:g.push(f);while(g.length>0){h=g.shift(),i=h.exec(b.trim());if(i!==null)return c.type=e,c.match=i,a.log.trace("Twig.logic.tokenize: ","Matched a ",e," regular expression of ",i),c}}throw new a.Error("Unable to parse '"+b.trim()+"'")},a.logic.parse=function(b,c,d){var e="",f;return c=c||{},a.log.debug("Twig.logic.parse: ","Parsing logic token ",b),f=a.logic.handler[b.type],f.parse&&(e=f.parse.apply(this,[b,c,d])),e},a}(Twig||{}),Twig=function(a){"use strict",a.expression={},a.expression.reservedWords=["true","false","null"],a.expression.type={comma:"Twig.expression.type.comma",expression:"Twig.expression.type.expression",operator:{unary:"Twig.expression.type.operator.unary",binary:"Twig.expression.type.operator.binary"},string:"Twig.expression.type.string",bool:"Twig.expression.type.bool",array:{start:"Twig.expression.type.array.start",end:"Twig.expression.type.array.end"},object:{start:"Twig.expression.type.object.start",end:"Twig.expression.type.object.end"},parameter:{start:"Twig.expression.type.parameter.start",end:"Twig.expression.type.parameter.end"},key:{period:"Twig.expression.type.key.period",brackets:"Twig.expression.type.key.brackets"},filter:"Twig.expression.type.filter",_function:"Twig.expression.type._function",variable:"Twig.expression.type.variable",number:"Twig.expression.type.number",_null:"Twig.expression.type.null",test:"Twig.expression.type.test"},a.expression.set={operations:[a.expression.type.filter,a.expression.type.operator.unary,a.expression.type.operator.binary,a.expression.type.array.end,a.expression.type.object.end,a.expression.type.parameter.end,a.expression.type.comma,a.expression.type.test],expressions:[a.expression.type._function,a.expression.type.expression,a.expression.type.bool,a.expression.type.string,a.expression.type.variable,a.expression.type.number,a.expression.type._null,a.expression.type.array.start,a.expression.type.object.start]},a.expression.set.operations_extended=a.expression.set.operations.concat([a.expression.type.key.period,a.expression.type.key.brackets]),a.expression.fn={compile:{push:function(a,b,c){c.push(a)},push_both:function(a,b,c){c.push(a),b.push(a)}},parse:{push:function(a,b,c){b.push(a)},push_value:function(a,b,c){b.push(a.value)}}},a.expression.definitions=[{type:a.expression.type.test,regex:/^is\s+(not)?\s*([a-zA-Z_][a-zA-Z0-9_]*)/,next:a.expression.set.operations.concat([a.expression.type.parameter.start]),compile:function(a,b,c){a.filter=a.match[2],a.modifier=a.match[1],delete a.match,delete a.value,c.push(a)},parse:function(b,c,d){var e=c.pop(),f=b.params&&a.expression.parse.apply(this,[b.params,d]),g=a.test(b.filter,e,f);b.modifier=="not"?c.push(!g):c.push(g)}},{type:a.expression.type.comma,regex:/^,/,next:a.expression.set.expressions,compile:function(b,c,d){var e=c.length-1,f;delete b.match,delete b.value;for(;e>=0;e--){f=c.pop();if(f.type===a.expression.type.object.start||f.type===a.expression.type.parameter.start||f.type===a.expression.type.array.start){c.push(f);break}d.push(f)}d.push(b)}},{type:a.expression.type.expression,regex:/^\(([^\)]+)\)/,next:a.expression.set.operations_extended,compile:function(b,c,d){b.value=b.match[1];var e=a.expression.compile(b).stack;while(e.length>0)d.push(e.shift())}},{type:a.expression.type.operator.binary,regex:/(^[\+\-~%\?\:]|^[!=]==?|^[!<>]=?|^\*\*?|^\/\/?|^and\s+|^or\s+|^in\s+|^not in\s+|^\.\.)/,next:a.expression.set.expressions.concat([a.expression.type.operator.unary]),compile:function(b,c,d){delete b.match,b.value=b.value.trim();var e=b.value,f=a.expression.operator.lookup(e,b);a.log.trace("Twig.expression.compile: ","Operator: ",f," from ",e);while(c.length>0&&(c[c.length-1].type==a.expression.type.operator.unary||c[c.length-1].type==a.expression.type.operator.binary)&&(f.associativity===a.expression.operator.leftToRight&&f.precidence>=c[c.length-1].precidence||f.associativity===a.expression.operator.rightToLeft&&f.precidence>c[c.length-1].precidence)){var g=c.pop();d.push(g)}if(e===":"){if(!c[c.length-1]||c[c.length-1].value!=="?"){var h=d.pop();if(h.type!==a.expression.type.string)throw new a.Error("Unexpected value before ':' of "+h.type+" = "+h.value);b.key=h.value,d.push(b);return}}else c.push(f)},parse:function(b,c,d){b.key?c.push(b):a.expression.operator.parse(b.value,c)}},{type:a.expression.type.operator.unary,regex:/(^not)/,next:a.expression.set.expressions,compile:function(b,c,d){delete b.match;var e=b.value.trim(),f=a.expression.operator.lookup(e,b);a.log.trace("Twig.expression.compile: ","Operator: ",f," from ",e);while(c.length>0&&(c[c.length-1].type==a.expression.type.operator.unary||c[c.length-1].type==a.expression.type.operator.binary)&&(f.associativity===a.expression.operator.leftToRight&&f.precidence>=c[c.length-1].precidence||f.associativity===a.expression.operator.rightToLeft&&f.precidence>c[c.length-1].precidence)){var g=c.pop();d.push(g)}c.push(f)},parse:function(b,c,d){a.expression.operator.parse(b.value,c)}},{type:a.expression.type.string,regex:/^(["'])(?:(?=(\\?))\2.)*?\1/,next:a.expression.set.operations,compile:function(b,c,d){var e=b.value;delete b.match,e.substring(0,1)==='"'?e=e.replace('\\"','"'):e=e.replace("\\'","'"),b.value=e.substring(1,e.length-1),a.log.trace("Twig.expression.compile: ","String value: ",b.value),d.push(b)},parse:a.expression.fn.parse.push_value},{type:a.expression.type.parameter.start,regex:/^\(/,next:a.expression.set.expressions.concat([a.expression.type.parameter.end]),compile:a.expression.fn.compile.push_both,parse:a.expression.fn.parse.push},{type:a.expression.type.parameter.end,regex:/^\)/,next:a.expression.set.operations_extended,compile:function(b,c,d){var e;e=c.pop();while(c.length>0&&e.type!=a.expression.type.parameter.start)d.push(e),e=c.pop();var f=[];while(b.type!==a.expression.type.parameter.start)f.unshift(b),b=d.pop();f.unshift(b),b=d.pop();if(b.type!==a.expression.type._function&&b.type!==a.expression.type.filter&&b.type!==a.expression.type.test&&b.type!==a.expression.type.key.brackets&&b.type!==a.expression.type.key.period)throw new a.Error("Expected filter or function before parameters, got "+b.type);b.params=f,d.push(b)},parse:function(b,c,d){var e=[],f=!1,g=null;while(c.length>0){g=c.pop();if(g&&g.type&&g.type==a.expression.type.parameter.start){f=!0;break}e.unshift(g)}if(!f)throw new a.Error("Expected end of parameter set.");c.push(e)}},{type:a.expression.type.array.start,regex:/^\[/,next:a.expression.set.expressions.concat([a.expression.type.array.end]),compile:a.expression.fn.compile.push_both,parse:a.expression.fn.parse.push},{type:a.expression.type.array.end,regex:/^\]/,next:a.expression.set.operations_extended,compile:function(b,c,d){var e=c.length-1,f;for(;e>=0;e--){f=c.pop();if(f.type===a.expression.type.array.start)break;d.push(f)}d.push(b)},parse:function(b,c,d){var e=[],f=!1,g=null;while(c.length>0){g=c.pop();if(g.type&&g.type==a.expression.type.array.start){f=!0;break}e.unshift(g)}if(!f)throw new a.Error("Expected end of array.");c.push(e)}},{type:a.expression.type.object.start,regex:/^\{/,next:a.expression.set.expressions.concat([a.expression.type.object.end]),compile:a.expression.fn.compile.push_both,parse:a.expression.fn.parse.push},{type:a.expression.type.object.end,regex:/^\}/,next:a.expression.set.operations_extended,compile:function(b,c,d){var e=c.length-1,f;for(;e>=0;e--){f=c.pop();if(f&&f.type===a.expression.type.object.start)break;d.push(f)}d.push(b)},parse:function(b,c,d){var e={},f=!1,g=null,h=null,i=!1,j=null;while(c.length>0){g=c.pop();if(g&&g.type&&g.type===a.expression.type.object.start){f=!0;break}if(g&&g.type&&(g.type===a.expression.type.operator.binary||g.type===a.expression.type.operator.unary)&&g.key){if(!i)throw new a.Error("Missing value for key '"+g.key+"' in object definition.");e[g.key]=j,e._keys===undefined&&(e._keys=[]),e._keys.unshift(g.key),j=null,i=!1}else i=!0,j=g}if(!f)throw new a.Error("Unexpected end of object.");c.push(e)}},{type:a.expression.type.filter,regex:/^\|\s?([a-zA-Z_][a-zA-Z0-9_\-]*)/,next:a.expression.set.operations_extended.concat([a.expression.type.parameter.start]),compile:function(a,b,c){a.value=a.match[1],c.push(a)},parse:function(b,c,d){var e=c.pop(),f=b.params&&a.expression.parse.apply(this,[b.params,d]);c.push(a.filter.apply(this,[b.value,e,f]))}},{type:a.expression.type._function,regex:/^([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/,next:a.expression.type.parameter.start,transform:function(a,b){return"("},compile:function(a,b,c){var d=a.match[1];a.fn=d,delete a.match,delete a.value,c.push(a)},parse:function(b,c,d){var e=b.params&&a.expression.parse.apply(this,[b.params,d]),f=b.fn,g;if(a.functions[f])g=a.functions[f].apply(this,e);else{if(typeof d[f]!="function")throw new a.Error(f+" function does not exist and is not defined in the context");g=d[f].apply(d,e)}c.push(g)}},{type:a.expression.type.variable,regex:/^[a-zA-Z_][a-zA-Z0-9_]*/,next:a.expression.set.operations_extended.concat([a.expression.type.parameter.start]),compile:a.expression.fn.compile.push,validate:function(b,c){return a.expression.reservedWords.indexOf(b[0])==-1},parse:function(b,c,d){var e=a.expression.resolve(d[b.value],d);c.push(e)}},{type:a.expression.type.key.period,regex:/^\.([a-zA-Z_][a-zA-Z0-9_]*)/,next:a.expression.set.operations_extended.concat([a.expression.type.parameter.start]),compile:function(a,b,c){a.key=a.match[1],delete a.match,delete a.value,c.push(a)},parse:function(b,c,d){var e=b.params&&a.expression.parse.apply(this,[b.params,d]),f=b.key,g=c.pop(),h;if(g===null||g===undefined){if(this.options.strict_variables)throw new a.Error("Can't access a key "+f+" on an null or undefined object.");return null}var i=function(a){return a.substr(0,1).toUpperCase()+a.substr(1)};typeof g=="object"&&f in g?h=g[f]:g["get"+i(f)]!==undefined?h=g["get"+i(f)]:g["is"+i(f)]!==undefined?h=g["is"+i(f)]:h=null,c.push(a.expression.resolve(h,g,e))}},{type:a.expression.type.key.brackets,regex:/^\[([^\]]*)\]/,next:a.expression.set.operations_extended.concat([a.expression.type.parameter.start]),compile:function(b,c,d){var e=b.match[1];delete b.value,delete b.match,b.stack=a.expression.compile({value:e}).stack,d.push(b)},parse:function(
b,c,d){var e=b.params&&a.expression.parse.apply(this,[b.params,d]),f=a.expression.parse.apply(this,[b.stack,d]),g=c.pop(),h;if(g===null||g===undefined){if(this.options.strict_variables)throw new a.Error("Can't access a key "+f+" on an null or undefined object.");return null}typeof g=="object"&&f in g?h=g[f]:h=null,c.push(a.expression.resolve(h,g,e))}},{type:a.expression.type._null,regex:/^null/,next:a.expression.set.operations,compile:function(a,b,c){delete a.match,a.value=null,c.push(a)},parse:a.expression.fn.parse.push_value},{type:a.expression.type.number,regex:/^\-?\d+(\.\d+)?/,next:a.expression.set.operations,compile:function(a,b,c){a.value=Number(a.value),c.push(a)},parse:a.expression.fn.parse.push_value},{type:a.expression.type.bool,regex:/^(true|false)/,next:a.expression.set.operations,compile:function(a,b,c){a.value=a.match[0]=="true",delete a.match,c.push(a)},parse:a.expression.fn.parse.push_value}],a.expression.resolve=function(a,b,c){return typeof a=="function"?a.apply(b,c||[]):a},a.expression.handler={},a.expression.extendType=function(b){a.expression.type[b]="Twig.expression.type."+b},a.expression.extend=function(b){if(!b.type)throw new a.Error("Unable to extend logic definition. No type provided for "+b);a.expression.handler[b.type]=b};while(a.expression.definitions.length>0)a.expression.extend(a.expression.definitions.shift());return a.expression.tokenize=function(b){var c=[],d=0,e=null,f,g,h,i,j,k=[],l;l=function(){var b=Array.prototype.slice.apply(arguments),g=b.pop(),h=b.pop();return a.log.trace("Twig.expression.tokenize","Matched a ",f," regular expression of ",b),e&&e.indexOf(f)<0?(k.push(f+" cannot follow a "+c[c.length-1].type+" at template:"+d+" near '"+b[0].substring(0,20)+"...'"),b[0]):a.expression.handler[f].validate&&!a.expression.handler[f].validate(b,c)?b[0]:(k=[],c.push({type:f,value:b[0],match:b}),j=!0,e=i,d+=b[0].length,a.expression.handler[f].transform?a.expression.handler[f].transform(b,c):"")},a.log.debug("Twig.expression.tokenize","Tokenizing expression ",b);while(b.length>0){b=b.trim();for(f in a.expression.handler)if(a.expression.handler.hasOwnProperty(f)){i=a.expression.handler[f].next,g=a.expression.handler[f].regex,g instanceof Array?h=g:h=[g],j=!1;while(h.length>0)g=h.pop(),b=b.replace(g,l);if(j)break}if(!j)throw k.length>0?new a.Error(k.join(" OR ")):new a.Error("Unable to parse '"+b+"' at template position"+d)}return a.log.trace("Twig.expression.tokenize","Tokenized to ",c),c},a.expression.compile=function(b){var c=b.value,d=a.expression.tokenize(c),e=null,f=[],g=[],h=null;a.log.trace("Twig.expression.compile: ","Compiling ",c);while(d.length>0)e=d.shift(),h=a.expression.handler[e.type],a.log.trace("Twig.expression.compile: ","Compiling ",e),h.compile&&h.compile(e,g,f),a.log.trace("Twig.expression.compile: ","Stack is",g),a.log.trace("Twig.expression.compile: ","Output is",f);while(g.length>0)f.push(g.pop());return a.log.trace("Twig.expression.compile: ","Final output is",f),b.stack=f,delete b.value,b},a.expression.parse=function(b,c){var d=this;b instanceof Array||(b=[b]);var e=[],f=null;return b.forEach(function(b){f=a.expression.handler[b.type],f.parse&&f.parse.apply(d,[b,e,c])}),e.pop()},a}(Twig||{}),Twig=function(a){"use strict",a.expression.operator={leftToRight:"leftToRight",rightToLeft:"rightToLeft"},a.expression.operator.lookup=function(b,c){switch(b){case"..":case"not in":case"in":c.precidence=20,c.associativity=a.expression.operator.leftToRight;break;case",":c.precidence=18,c.associativity=a.expression.operator.leftToRight;break;case"?":case":":c.precidence=16,c.associativity=a.expression.operator.rightToLeft;break;case"or":c.precidence=14,c.associativity=a.expression.operator.leftToRight;break;case"and":c.precidence=13,c.associativity=a.expression.operator.leftToRight;break;case"==":case"!=":c.precidence=9,c.associativity=a.expression.operator.leftToRight;break;case"<":case"<=":case">":case">=":c.precidence=8,c.associativity=a.expression.operator.leftToRight;break;case"~":case"+":case"-":c.precidence=6,c.associativity=a.expression.operator.leftToRight;break;case"//":case"**":case"*":case"/":case"%":c.precidence=5,c.associativity=a.expression.operator.leftToRight;break;case"not":c.precidence=3,c.associativity=a.expression.operator.rightToLeft;break;default:throw new a.Error(b+" is an unknown operator.")}return c.operator=b,c},a.expression.operator.parse=function(c,d){a.log.trace("Twig.expression.operator.parse: ","Handling ",c);var e,f,g;switch(c){case":":break;case"?":g=d.pop(),f=d.pop(),e=d.pop(),e?d.push(f):d.push(g);break;case"+":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(e+f);break;case"-":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(e-f);break;case"*":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(e*f);break;case"/":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(e/f);break;case"//":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(parseInt(e/f));break;case"%":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(e%f);break;case"~":f=d.pop(),e=d.pop(),d.push((e!==undefined?e.toString():"")+(f!==undefined?f.toString():""));break;case"not":case"!":d.push(!d.pop());break;case"<":f=d.pop(),e=d.pop(),d.push(e<f);break;case"<=":f=d.pop(),e=d.pop(),d.push(e<=f);break;case">":f=d.pop(),e=d.pop(),d.push(e>f);break;case">=":f=d.pop(),e=d.pop(),d.push(e>=f);break;case"===":f=d.pop(),e=d.pop(),d.push(e===f);break;case"==":f=d.pop(),e=d.pop(),d.push(e==f);break;case"!==":f=d.pop(),e=d.pop(),d.push(e!==f);break;case"!=":f=d.pop(),e=d.pop(),d.push(e!=f);break;case"or":f=d.pop(),e=d.pop(),d.push(e||f);break;case"and":f=d.pop(),e=d.pop(),d.push(e&&f);break;case"**":f=d.pop(),e=d.pop(),d.push(Math.pow(e,f));break;case"not in":f=d.pop(),e=d.pop(),d.push(!b(e,f));break;case"in":f=d.pop(),e=d.pop(),d.push(b(e,f));break;case"..":f=d.pop(),e=d.pop(),d.push(a.functions.range(e,f));break;default:throw new a.Error(c+" is an unknown operator.")}};var b=function(a,b){if(b.indexOf!=undefined)return b.indexOf(a)>-1;var c;for(c in b)if(b.hasOwnProperty(c)&&b[c]===a)return!0;return!1};return a}(Twig||{}),Twig=function(a){function b(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return b!==undefined&&b!==null&&c===a}return a.filters={upper:function(a){return a.toUpperCase()},lower:function(a){return a.toLowerCase()},capitalize:function(a){return a.substr(0,1).toUpperCase()+a.substr(1)},title:function(a){return a.replace(/(^|\s)([a-z])/g,function(a,b,c){return b+c.toUpperCase()})},length:function(a){if(a instanceof Array||typeof a=="string")return a.length;if(a instanceof Object)return a._keys===undefined?Object.keys(a).length:a._keys.length},reverse:function(a){if(b("Array",a))return a.reverse();if(b("String",a))return a.split("").reverse().join("");var c=a._keys||Object.keys(a).reverse();return a._keys=c,a},sort:function(a){if(b("Array",a))return a.sort();if(a instanceof Object){delete a._keys;var c=Object.keys(a),d=c.sort(function(b,c){return a[b]>a[c]});return a._keys=d,a}},keys:function(a){var b=a._keys||Object.keys(a),c=[];return b.forEach(function(b){if(b==="_keys")return;a.hasOwnProperty(b)&&c.push(b)}),c},url_encode:function(a){return encodeURIComponent(a)},join:function(a,b){var c="",d=[],e=null;return b&&b[0]&&(c=b[0]),a instanceof Array?d=a:(e=a._keys||Object.keys(a),e.forEach(function(b){if(b==="_keys")return;a.hasOwnProperty(b)&&d.push(a[b])})),d.join(c)},"default":function(b,c){if(c===undefined||c.length!==1)throw new a.Error("default filter expects one argument");return b===undefined||b===null||b===""?c[0]:b},json_encode:function(a){return delete a._keys,JSON.stringify(a)},merge:function(b,c){var d=[],e=0,f=[];b instanceof Array?c.forEach(function(a){a instanceof Array||(d={})}):d={},d instanceof Array||(d._keys=[]),b instanceof Array?b.forEach(function(a){d._keys&&d._keys.unshift(e),d[e]=a,e++}):(f=b._keys||Object.keys(b),f.forEach(function(a){d[a]=b[a],d._keys.push(a);var c=parseInt(a,10);!isNaN(c)&&c>=e&&(e=c+1)})),c.forEach(function(a){a instanceof Array?a.forEach(function(a){d._keys&&d._keys.push(e),d[e]=a,e++}):(f=a._keys||Object.keys(a),f.forEach(function(b){d[b]||d._keys.unshift(b),d[b]=a[b];var c=parseInt(b,10);!isNaN(c)&&c>=e&&(e=c+1)}))});if(c.length===0)throw new a.Error("Filter merge expects at least one parameter");return d},date:function(b,c){var d=a.functions.date(b);return a.lib.formatDate(d,c[0])},replace:function(a,b){var c=b[0],d;for(d in c)c.hasOwnProperty(d)&&d!=="_keys"&&(a=a.replace(d,c[d]));return a},format:function(b,c){return a.lib.vsprintf(b,c)},striptags:function(b){return a.lib.strip_tags(b)},escape:function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")},e:function(b){return a.filters.escape(b)},nl2br:function(b){var c="<br />";return a.filters.escape(b).replace(/\r\n/g,c).replace(/\r/g,c).replace(/\n/g,c)},number_format:function(a,b){var c=a;if(b instanceof Array)var d=b[0]?b[0]:undefined,e=b[1]?b[1]:undefined,f=b[2]?b[2]:undefined;c=(c+"").replace(/[^0-9+\-Ee.]/g,"");var g=isFinite(+c)?+c:0,h=isFinite(+d)?Math.abs(d):0,i=typeof f=="undefined"?",":f,j=typeof e=="undefined"?".":e,k="",l=function(a,b){var c=Math.pow(10,b);return""+Math.round(a*c)/c};return k=(h?l(g,h):""+Math.round(g)).split("."),k[0].length>3&&(k[0]=k[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,i)),(k[1]||"").length<h&&(k[1]=k[1]||"",k[1]+=(new Array(h-k[1].length+1)).join("0")),k.join(j)},trim:function(a,b){var c=a,d=" \n\r\t\f             ​\u2028\u2029 ";for(var e=0;e<c.length;e++)if(d.indexOf(c.charAt(e))===-1){c=c.substring(e);break}for(e=c.length-1;e>=0;e--)if(d.indexOf(c.charAt(e))===-1){c=c.substring(0,e+1);break}return d.indexOf(c.charAt(0))===-1?c:""}},a.filter=function(b,c,d){if(!a.filters[b])throw"Unable to find filter "+b;return a.filters[b].apply(this,[c,d])},a.filter.extend=function(b,c){a.filters[b]=c},a}(Twig||{}),Twig=function(a){function b(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return b!==undefined&&b!==null&&c===a}return a.functions={range:function(a,b,c){var d=[],e,f,g,h=c||1,i=!1;!isNaN(a)&&!isNaN(b)?(e=parseInt(a,10),f=parseInt(b,10)):isNaN(a)&&isNaN(b)?(i=!0,e=a.charCodeAt(0),f=b.charCodeAt(0)):(e=isNaN(a)?0:a,f=isNaN(b)?0:b),g=e>f?!1:!0;if(g)while(e<=f)d.push(i?String.fromCharCode(e):e),e+=h;else while(e>=f)d.push(i?String.fromCharCode(e):e),e-=h;return d},cycle:function(a,b){var c=b%a.length;return a[c]},dump:function(){var a="\n",b=" ",c=0,d="",e=Array.prototype.slice.call(arguments),f=function(a){var c="";while(a>0)a--,c+=b;return c},g=function(b){d+=f(c),typeof b=="object"?h(b):typeof b=="function"?d+="function()"+a:typeof b=="string"?d+="string("+b.length+') "'+b+'"'+a:typeof b=="number"?d+="number("+b+")"+a:typeof b=="boolean"&&(d+="bool("+b+")"+a)},h=function(b){var e;if(b===null)d+="NULL"+a;else if(b===undefined)d+="undefined"+a;else if(typeof b=="object"){d+=f(c)+typeof b,c++,d+="("+function(a){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(b)+") {"+a;for(e in b)d+=f(c)+"["+e+"]=> "+a,g(b[e]);c--,d+=f(c)+"}"+a}else g(b)};return e.length==0&&e.push(this.context),e.forEach(function(a){h(a)}),d},date:function(b,c){var d;if(b==undefined)d=new Date;else if(a.lib.is("Date",b))d=b;else if(a.lib.is("String",b))d=new Date(a.lib.strtotime(b)*1e3);else{if(!a.lib.is("Number",b))throw new a.Error("Unable to parse date "+b);d=new Date(b*1e3)}return d},parent:function(){return a.placeholders.parent}},a._function=function(b,c,d){if(!a.functions[b])throw"Unable to find function "+b;return a.functions[b](c,d)},a._function.extend=function(b,c){a.functions[b]=c},a}(Twig||{}),Twig=function(a){return"use strict",a.tests={empty:function(a){if(a===null||a===undefined)return!0;if(typeof a=="number")return!1;if(a.length&&a.length>0)return!1;for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},odd:function(a){return a%2===1},even:function(a){return a%2===0},divisibleby:function(a,b){return a%b[0]===0},defined:function(a){return a!==undefined},none:function(a){return a===null},"null":function(a){return this.none(a)},sameas:function(a,b){return a===b[0]}},a.test=function(b,c,d){if(!a.tests[b])throw"Test "+b+" is not defined.";return a.tests[b](c,d)},a.test.extend=function(b,c){a.tests[b]=c},a}(Twig||{}),Twig=function(a){return"use strict",a.exports={},a.exports.twig=function(c){"use strict";var d=c.id,e={strict_variables:c.strict_variables||!1};d&&a.validateId(d),c.debug!==undefined&&(a.debug=c.debug),c.trace!==undefined&&(a.trace=c.trace);if(c.data!==undefined)return new a.Template({data:c.data,module:c.module,id:d,options:e});if(c.ref!==undefined){if(c.id!==undefined)throw new Error("Both ref and id cannot be set on a twig.js template.");return a.Templates.load(c.ref)}if(c.href!==undefined)return a.Templates.loadRemote(c.href,{id:d,module:c.module,precompiled:c.precompiled,method:"ajax",async:c.async,options:e},c.load,c.error);if(c.path!==undefined)return a.Templates.loadRemote(c.path,{id:d,module:c.module,precompiled:c.precompiled,method:"fs",async:c.async,options:e},c.load,c.error)},a.exports.extendFilter=function(b,c){a.filter.extend(b,c)},a.exports.extendFunction=function(b,c){a._function.extend(b,c)},a.exports.extendTest=function(b,c){a.test.extend(b,c)},a.exports.extendTag=function(b){a.logic.extend(b)},a.exports.compile=function(b,c){var d=c.filename,e="/",f=c.filename,g;return g=new a.Template({data:b,path:f,id:d,options:c.settings["twig options"]}),function(a){return g.render(a)}},a.exports.renderFile=function(b,c,d){"function"==typeof c&&(d=c,c={});var e=c.settings["twig options"],f,g={path:b,load:function(a){d(null,a.render(c))}};if(e)for(f in e)g[f]=e[f];a.exports.twig(g)},a.exports.__express=a.exports.renderFile,a.exports.cache=function(b){a.cache=b},a}(Twig||{}),Twig=function(a){return a.compiler={module:{}},a.compiler.compile=function(b,c){var d=JSON.stringify(b.tokens),e=b.id,f;if(c.module){if(a.compiler.module[c.module]===undefined)throw new a.Error("Unable to find module type "+c.module);f=a.compiler.module[c.module](e,d,c.twig)}else f=a.compiler.wrap(e,d);return f},a.compiler.module={amd:function(b,c,d){return'define(["'+d+'"], function (Twig) {\n\tvar twig = Twig.twig;\n'+a.compiler.wrap(b,c)+"\n\treturn templates;\n});"},node:function(b,c){return'var twig = require("twig").twig;\nexports.template = '+a.compiler.wrap(b,c)},cjs2:function(b,c,d){return'module.declare([{ twig: "'+d+'" }], function (require, exports, module) {\n'+'\tvar twig = require("twig").twig;\n'+"\texports.template = "+a.compiler.wrap(b,c)+"\n});"}},a.compiler.wrap=function(a,b){return'twig({id:"'+a.replace('"','\\"')+'", data:'+b+", precompiled: true});\n"},a}(Twig||{});typeof module!="undefined"&&module.declare?module.declare([],function(a,b,c){for(key in Twig.exports)Twig.exports.hasOwnProperty(key)&&(b[key]=Twig.exports[key])}):typeof module!="undefined"&&module.exports?module.exports=Twig.exports:(window.twig=Twig.exports.twig,window.Twig=Twig.exports);
var Twig=function(a){function b(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return b!==undefined&&b!==null&&c===a}function c(b,c){var d,e,f="/",g=[],h;if(b.url)d=b.url;else{if(!b.path)throw new a.Error("Cannot extend an inline template.");d=b.path}e=d.split(f),e.pop(),e=e.concat(c.split(f));while(e.length>0)h=e.shift(),h!="."&&(h==".."&&g.length>0&&g[g.length-1]!=".."?g.pop():g.push(h));return g.join(f)}return"use strict",a.trace=!1,a.debug=!1,a.cache=!0,a.placeholders={parent:"{{|PARENT|}}"},a.Error=function(a){this.message=a,this.name="TwigException",this.type="TwigException"},a.Error.prototype.toString=function(){return this.name+": "+this.message},a.log={trace:function(){a.trace&&console&&console.log(Array.prototype.slice.call(arguments))},debug:function(){a.debug&&console&&console.log(Array.prototype.slice.call(arguments))}},a.token={},a.token.type={output:"output",logic:"logic",comment:"comment",raw:"raw"},a.token.definitions={output:{type:a.token.type.output,open:"{{",close:"}}"},logic:{type:a.token.type.logic,open:"{%",close:"%}"},comment:{type:a.token.type.comment,open:"{#",close:"#}"}},a.token.strings=['"',"'"],a.token.findStart=function(b){var c={position:null,def:null},d,e,f;for(d in a.token.definitions)a.token.definitions.hasOwnProperty(d)&&(e=a.token.definitions[d],f=b.indexOf(e.open),a.log.trace("Twig.token.findStart: ","Searching for ",e.open," found at ",f),f>=0&&(c.position===null||f<c.position)&&(c.position=f,c.def=e));return c},a.token.findEnd=function(b,c,d){var e=null,f=!1,g=0,h=null,i=null,j=null,k=null,l=null,m=null,n,o;while(!f){h=null,i=null,j=b.indexOf(c.close,g);if(!(j>=0))throw new a.Error("Unable to find closing bracket '"+c.close+"'"+" opened near template position "+d);e=j,f=!0,o=a.token.strings.length;for(n=0;n<o;n+=1)l=b.indexOf(a.token.strings[n],g),l>0&&l<j&&(h===null||l<h)&&(h=l,i=a.token.strings[n]);if(h!==null){k=h+1,e=null,f=!1;for(;;){m=b.indexOf(i,k);if(m<0)throw"Unclosed string in template";if(b.substr(m-1,1)!=="\\"){g=m+1;break}k=m+1}}}return e},a.tokenize=function(b){var c=[],d=0,e=null,f=null;while(b.length>0)e=a.token.findStart(b),a.log.trace("Twig.tokenize: ","Found token: ",e),e.position!==null?(e.position>0&&c.push({type:a.token.type.raw,value:b.substring(0,e.position)}),b=b.substr(e.position+e.def.open.length),d+=e.position+e.def.open.length,f=a.token.findEnd(b,e.def,d),a.log.trace("Twig.tokenize: ","Token ends at ",f),c.push({type:e.def.type,value:b.substring(0,f).trim()}),b=b.substr(f+e.def.close.length),d+=f+e.def.close.length):(c.push({type:a.token.type.raw,value:b}),b="");return c},a.compile=function(b){var c=[],d=[],e=[],f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=null;while(b.length>0){f=b.shift(),a.log.trace("Compiling token ",f);switch(f.type){case a.token.type.raw:d.length>0?e.push(f):c.push(f);break;case a.token.type.logic:g=a.logic.compile.apply(this,[f]),l=g.type,m=a.logic.handler[l].open,n=a.logic.handler[l].next,a.log.trace("Twig.compile: ","Compiled logic token to ",g," next is: ",n," open is : ",m);if(m!==undefined&&!m){i=d.pop(),j=a.logic.handler[i.type];if(j.next.indexOf(l)<0)throw new Error(l+" not expected after a "+i.type);i.output=i.output||[],i.output=i.output.concat(e),e=[],k={type:a.token.type.logic,token:i},d.length>0?e.push(k):c.push(k)}n!==undefined&&n.length>0?(a.log.trace("Twig.compile: ","Pushing ",g," to logic stack."),d.length>0&&(i=d.pop(),i.output=i.output||[],i.output=i.output.concat(e),d.push(i),e=[]),d.push(g)):m!==undefined&&m&&(k={type:a.token.type.logic,token:g},d.length>0?e.push(k):c.push(k));break;case a.token.type.comment:break;case a.token.type.output:a.expression.compile.apply(this,[f]),d.length>0?e.push(f):c.push(f)}a.log.trace("Twig.compile: "," Output: ",c," Logic Stack: ",d," Pending Output: ",e)}if(d.length>0)throw h=d.pop(),new Error("Unable to find an end tag for "+h.type+", expecting one of "+h.next);return c},a.parse=function(b,c){var d=[],e=!0,f=this;return c=c||{},b.forEach(function(b){a.log.debug("Twig.parse: ","Parsing token: ",b);switch(b.type){case a.token.type.raw:d.push(b.value);break;case a.token.type.logic:var g=b.token,h=a.logic.parse.apply(f,[g,c,e]);h.chain!==undefined&&(e=h.chain),h.context!==undefined&&(c=h.context),h.output!==undefined&&d.push(h.output);break;case a.token.type.comment:break;case a.token.type.output:d.push(a.expression.parse.apply(f,[b.stack,c]))}}),d.join("")},a.prepare=function(b){var c,d;return a.log.debug("Twig.prepare: ","Tokenizing ",b),d=a.tokenize.apply(this,[b]),a.log.debug("Twig.prepare: ","Compiling ",d),c=a.compile.apply(this,[d]),a.log.debug("Twig.prepare: ","Compiled ",c),c},a.Templates={registry:{}},a.validateId=function(b){if(b==="prototype")throw new a.Error(b+" is not a valid twig identifier");if(a.Templates.registry.hasOwnProperty(b))throw new a.Error("There is already a template with the ID "+b);return!0},a.Templates.save=function(b){if(b.id===undefined)throw new a.Error("Unable to save template with no id");a.Templates.registry[b.id]=b},a.Templates.load=function(b){return a.Templates.registry.hasOwnProperty(b)?a.Templates.registry[b]:null},a.Templates.loadRemote=function(b,c,d,e){var f=c.id,g=c.method,h=c.async,i=c.precompiled,j=c.options,k=null;h===undefined&&(h=!0),f===undefined&&(f=b);if(a.cache&&a.Templates.registry.hasOwnProperty(f))return d&&d(a.Templates.registry[f]),a.Templates.registry[f];if(g=="ajax"){if(typeof XMLHttpRequest=="undefined")throw new Error("Unsupported platform: Unable to do remote requests because there is no XMLHTTPRequest implementation");var l=new XMLHttpRequest;l.onreadystatechange=function(){var c=null;l.readyState==4&&(a.log.debug("Got template ",l.responseText),i===!0?c=JSON.parse(l.responseText):c=l.responseText,k=new a.Template({data:c,id:f,url:b,options:j}),d&&d(k))},l.open("GET",b,h),l.send()}else(function(){var c=require("fs"),g=null;h===!0?c.readFile(b,"utf8",function(c,g){if(c){e&&e(c);return}i===!0&&(g=JSON.parse(g)),k=new a.Template({data:g,id:f,path:b,options:j}),d&&d(k)}):(g=c.readFileSync(b,"utf8"),i===!0&&(g=JSON.parse(g)),k=new a.Template({data:g,id:f,path:b,options:j}),d&&d(k))})();return h===!1?k:!0},a.Template=function(c){var d=c.data,e=c.id,f=c.blocks,g=c.path,h=c.url,i=c.options;this.id=e,this.path=g,this.url=h,this.options=i,this.reset(f),b("String",d)?this.tokens=a.prepare.apply(this,[d]):this.tokens=d,e!==undefined&&a.Templates.save(this)},a.Template.prototype.reset=function(b){a.log.debug("Twig.Template.reset","Reseting template "+this.id),this.blocks={},this.child={blocks:b||{}},this.extend=null},a.Template.prototype.render=function(b,d){d=d||{};var e,f;return this.context=b||{},this.reset(),d.blocks&&(this.blocks=d.blocks),e=a.parse.apply(this,[this.tokens,this.context]),this.extend?(f=c(this,this.extend),this.parent=a.Templates.loadRemote(f,{method:this.url?"ajax":"fs",async:!1,id:f}),this.parent.render(this.context,{blocks:this.blocks})):d.output=="blocks"?this.blocks:e},a.Template.prototype.importFile=function(b){var d=c(this,b),e=a.Templates.loadRemote(d,{method:this.url?"ajax":"fs",async:!1,id:d});return e},a.Template.prototype.importBlocks=function(a,b){var c=this.importFile(a),d=this.context,e=this,f;b=b||!1,c.render(d),Object.keys(c.blocks).forEach(function(a){if(b||e.blocks[a]===undefined)e.blocks[a]=c.blocks[a]})},a.Template.prototype.compile=function(b){return a.compiler.compile(this,b)},a}(Twig||{});(function(){"use strict",String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){if(this===void 0||this===null)throw new TypeError;var b=Object(this),c=b.length>>>0;if(c===0)return-1;var d=0;arguments.length>0&&(d=Number(arguments[1]),d!==d?d=0:d!==0&&d!==Infinity&&d!==-Infinity&&(d=(d>0||-1)*Math.floor(Math.abs(d))));if(d>=c)return-1;var e=d>=0?d:Math.max(c-Math.abs(d),0);for(;e<c;e++)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c,d;if(this==null)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if({}.toString.call(a)!="[object Function]")throw new TypeError(a+" is not a function");b&&(c=b),d=0;while(d<f){var g;d in e&&(g=e[d],a.call(c,g,d,e)),d++}}),Object.keys||(Object.keys=function(a){if(a!==Object(a))throw new TypeError("Object.keys called on non-object");var b=[],c;for(c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b})})();var Twig=function(a){a.lib={};var b=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function c(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")}var d=function(){return d.cache.hasOwnProperty(arguments[0])||(d.cache[arguments[0]]=d.parse(arguments[0])),d.format.call(null,d.cache[arguments[0]],arguments)};return d.format=function(d,e){var f=1,g=d.length,h="",i,j=[],k,l,m,n,o,p;for(k=0;k<g;k++){h=a(d[k]);if(h==="string")j.push(d[k]);else if(h==="array"){m=d[k];if(m[2]){i=e[f];for(l=0;l<m[2].length;l++){if(!i.hasOwnProperty(m[2][l]))throw b('[sprintf] property "%s" does not exist',m[2][l]);i=i[m[2][l]]}}else m[1]?i=e[m[1]]:i=e[f++];if(/[^s]/.test(m[8])&&a(i)!="number")throw b("[sprintf] expecting number but found %s",a(i));switch(m[8]){case"b":i=i.toString(2);break;case"c":i=String.fromCharCode(i);break;case"d":i=parseInt(i,10);break;case"e":i=m[7]?i.toExponential(m[7]):i.toExponential();break;case"f":i=m[7]?parseFloat(i).toFixed(m[7]):parseFloat(i);break;case"o":i=i.toString(8);break;case"s":i=(i=String(i))&&m[7]?i.substring(0,m[7]):i;break;case"u":i=Math.abs(i);break;case"x":i=i.toString(16);break;case"X":i=i.toString(16).toUpperCase()}i=/[def]/.test(m[8])&&m[3]&&i>=0?"+"+i:i,o=m[4]?m[4]=="0"?"0":m[4].charAt(1):" ",p=m[6]-String(i).length,n=m[6]?c(o,p):"",j.push(m[5]?i+n:n+i)}}return j.join("")},d.cache={},d.parse=function(a){var b=a,c=[],d=[],e=0;while(b){if((c=/^[^\x25]+/.exec(b))!==null)d.push(c[0]);else if((c=/^\x25{2}/.exec(b))!==null)d.push("%");else{if((c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b))===null)throw"[sprintf] huh?";if(c[2]){e|=1;var f=[],g=c[2],h=[];if((h=/^([a-z_][a-z_\d]*)/i.exec(g))===null)throw"[sprintf] huh?";f.push(h[1]);while((g=g.substring(h[0].length))!=="")if((h=/^\.([a-z_][a-z_\d]*)/i.exec(g))!==null)f.push(h[1]);else{if((h=/^\[(\d+)\]/.exec(g))===null)throw"[sprintf] huh?";f.push(h[1])}c[2]=f}else e|=2;if(e===3)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";d.push(c)}b=b.substring(c[0].length)}return d},d}(),c=function(a,c){return c.unshift(a),b.apply(null,c)};return a.lib.sprintf=b,a.lib.vsprintf=c,function(){function f(a){return(a=Math.abs(a)%100)%10==1&&a!=11?"st":a%10==2&&a!=12?"nd":a%10==3&&a!=13?"rd":"th"}function g(a){var b=new Date(a.getFullYear()+1,0,4);return(b-a)/864e5<7&&(a.getDay()+6)%7<(b.getDay()+6)%7?b.getFullYear():a.getMonth()>0||a.getDate()>=4?a.getFullYear():a.getFullYear()-((a.getDay()+6)%7-a.getDate()>2?1:0)}function h(a){var b=new Date(g(a),0,4);return b.setDate(b.getDate()-(b.getDay()+6)%7),parseInt((a-b)/6048e5)+1}var b="Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(","),c="Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),d="Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),e="January,February,March,April,May,June,July,August,September,October,November,December".split(",");a.lib.formatDate=function(a,i){if(typeof i!="string"||/^\s*$/.test(i))return a+"";var j=new Date(a.getFullYear(),0,1),k=a;return i.replace(/[dDjlNSwzWFmMntLoYyaABgGhHisu]/g,function(a){switch(a){case"d":return("0"+k.getDate()).replace(/^.+(..)$/,"$1");case"D":return b[k.getDay()];case"j":return k.getDate();case"l":return c[k.getDay()];case"N":return(k.getDay()+6)%7+1;case"S":return f(k.getDate());case"w":return k.getDay();case"z":return Math.ceil((j-k)/864e5);case"W":return("0"+h(k)).replace(/^.(..)$/,"$1");case"F":return e[k.getMonth()];case"m":return("0"+(k.getMonth()+1)).replace(/^.+(..)$/,"$1");case"M":return d[k.getMonth()];case"n":return k.getMonth()+1;case"t":return(new Date(k.getFullYear(),k.getMonth()+1,-1)).getDate();case"L":return(new Date(k.getFullYear(),1,29)).getDate()==29?1:0;case"o":return g(k);case"Y":return k.getFullYear();case"y":return(k.getFullYear()+"").replace(/^.+(..)$/,"$1");case"a":return k.getHours()<12?"am":"pm";case"A":return k.getHours()<12?"AM":"PM";case"B":return Math.floor(((k.getUTCHours()+1)%24+k.getUTCMinutes()/60+k.getUTCSeconds()/3600)*1e3/24);case"g":return k.getHours()%12!=0?k.getHours()%12:12;case"G":return k.getHours();case"h":return("0"+(k.getHours()%12!=0?k.getHours()%12:12)).replace(/^.+(..)$/,"$1");case"H":return("0"+k.getHours()).replace(/^.+(..)$/,"$1");case"i":return("0"+k.getMinutes()).replace(/^.+(..)$/,"$1");case"s":return("0"+k.getSeconds()).replace(/^.+(..)$/,"$1");case"u":return k.getMilliseconds()}})}}(),a.lib.strip_tags=function(a,b){b=(((b||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join("");var c=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,d=/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;return a.replace(d,"").replace(c,function(a,c){return b.indexOf("<"+c.toLowerCase()+">")>-1?a:""})},a.lib.strtotime=function(a,b){var c,d,e,f,g="";a=a.replace(/\s{2,}|^\s|\s$/g," "),a=a.replace(/[\t\r\n]/g,"");if(a==="now")return b===null||isNaN(b)?(new Date).getTime()/1e3|0:b|0;if(!isNaN(g=Date.parse(a)))return g/1e3|0;b?b=new Date(b*1e3):b=new Date,a=a.toLowerCase();var h={day:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6},mon:["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]},i=function(a){var c=a[2]&&a[2]==="ago",d=(d=a[0]==="last"?-1:1)*(c?-1:1);switch(a[0]){case"last":case"next":switch(a[1].substring(0,3)){case"yea":b.setFullYear(b.getFullYear()+d);break;case"wee":b.setDate(b.getDate()+d*7);break;case"day":b.setDate(b.getDate()+d);break;case"hou":b.setHours(b.getHours()+d);break;case"min":b.setMinutes(b.getMinutes()+d);break;case"sec":b.setSeconds(b.getSeconds()+d);break;case"mon":if(a[1]==="month"){b.setMonth(b.getMonth()+d);break};default:var e=h.day[a[1].substring(0,3)];if(typeof e!="undefined"){var f=e-b.getDay();f===0?f=7*d:f>0?a[0]==="last"&&(f-=7):a[0]==="next"&&(f+=7),b.setDate(b.getDate()+f),b.setHours(0,0,0,0)}}break;default:if(!/\d+/.test(a[0]))return!1;d*=parseInt(a[0],10);switch(a[1].substring(0,3)){case"yea":b.setFullYear(b.getFullYear()+d);break;case"mon":b.setMonth(b.getMonth()+d);break;case"wee":b.setDate(b.getDate()+d*7);break;case"day":b.setDate(b.getDate()+d);break;case"hou":b.setHours(b.getHours()+d);break;case"min":b.setMinutes(b.getMinutes()+d);break;case"sec":b.setSeconds(b.getSeconds()+d)}}return!0};e=a.match(/^(\d{2,4}-\d{2}-\d{2})(?:\s(\d{1,2}:\d{2}(:\d{2})?)?(?:\.(\d+))?)?$/);if(e!==null)return e[2]?e[3]||(e[2]+=":00"):e[2]="00:00:00",f=e[1].split(/-/g),f[1]=h.mon[f[1]-1]||f[1],f[0]=+f[0],f[0]=f[0]>=0&&f[0]<=69?"20"+(f[0]<10?"0"+f[0]:f[0]+""):f[0]>=70&&f[0]<=99?"19"+f[0]:f[0]+"",parseInt(this.strtotime(f[2]+" "+f[1]+" "+f[0]+" "+e[2])+(e[4]?e[4]/1e3:""),10);var j="([+-]?\\d+\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday)|(last|next)\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday))(\\sago)?";e=a.match(new RegExp(j,"gi"));if(e===null)return!1;for(c=0,d=e.length;c<d;c++)if(!i(e[c].split(" ")))return!1;return b.getTime()/1e3|0},a.lib.is=function(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return b!==undefined&&b!==null&&c===a},a.lib.copy=function(a){var b={},c;for(c in a)b[c]=a[c];return b},a}(Twig||{}),Twig=function(a){"use strict",a.logic={},a.logic.type={if_:"Twig.logic.type.if",endif:"Twig.logic.type.endif",for_:"Twig.logic.type.for",endfor:"Twig.logic.type.endfor",else_:"Twig.logic.type.else",elseif:"Twig.logic.type.elseif",set:"Twig.logic.type.set",filter:"Twig.logic.type.filter",endfilter:"Twig.logic.type.endfilter",block:"Twig.logic.type.block",endblock:"Twig.logic.type.endblock",extends_:"Twig.logic.type.extends",use:"Twig.logic.type.use",include:"Twig.logic.type.include"},a.logic.definitions=[{type:a.logic.type.if_,regex:/^if\s+([^\s].+)$/,next:[a.logic.type.else_,a.logic.type.elseif,a.logic.type.endif],open:!0,compile:function(b){var c=b.match[1];return b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:c}]).stack,delete b.match,b},parse:function(b,c,d){var e="",f=a.expression.parse.apply(this,[b.stack,c]);return d=!0,f&&(d=!1,e=a.parse.apply(this,[b.output,c])),{chain:d,output:e}}},{type:a.logic.type.elseif,regex:/^elseif\s+([^\s].*)$/,next:[a.logic.type.else_,a.logic.type.elseif,a.logic.type.endif],open:!1,compile:function(b){var c=b.match[1];return b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:c}]).stack,delete b.match,b},parse:function(b,c,d){var e="";return d&&a.expression.parse.apply(this,[b.stack,c])===!0&&(d=!1,e=a.parse.apply(this,[b.output,c])),{chain:d,output:e}}},{type:a.logic.type.else_,regex:/^else$/,next:[a.logic.type.endif,a.logic.type.endfor],open:!1,parse:function(b,c,d){var e="";return d&&(e=a.parse.apply(this,[b.output,c])),{chain:d,output:e}}},{type:a.logic.type.endif,regex:/^endif$/,next:[],open:!1},{type:a.logic.type.for_,regex:/^for\s+([a-zA-Z0-9_,\s]+)\s+in\s+([^\s].*?)(?:\s+if\s+([^\s].*))?$/,next:[a.logic.type.else_,a.logic.type.endfor],open:!0,compile:function(b){var c=b.match[1],d=b.match[2],e=b.match[3],f=null;b.key_var=null,b.value_var=null;if(c.indexOf(",")>=0){f=c.split(",");if(f.length!==2)throw new a.Error("Invalid expression in for loop: "+c);b.key_var=f[0].trim(),b.value_var=f[1].trim()}else b.value_var=c;return b.expression=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:d}]).stack,e&&(b.conditional=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:e}]).stack),delete b.match,b},parse:function(b,c,d){var e=a.expression.parse.apply(this,[b.expression,c]),f=[],g,h=0,i,j=this,k=b.conditional,l=function(a,b){var d=k!==undefined;return{index:a+1,index0:a,revindex:d?undefined:b-a,revindex0:d?undefined:b-a-1,first:a===0,last:d?undefined:a===b-1,length:d?undefined:b,parent:c}},m=function(d,e){var i=a.lib.copy(c);i[b.value_var]=e,b.key_var&&(i[b.key_var]=d),i.loop=l(h,g);if(k===undefined||a.expression.parse.apply(j,[k,i]))f.push(a.parse.apply(j,[b.output,i])),h+=1};return e instanceof Array?(g=e.length,e.forEach(function(a){var b=h;m(b,a)})):e instanceof Object&&(e._keys!==undefined?i=e._keys:i=Object.keys(e),g=i.length,i.forEach(function(a){if(a==="_keys")return;m(a,e[a])})),d=f.length===0,{chain:d,output:f.join("")}}},{type:a.logic.type.endfor,regex:/^endfor$/,next:[],open:!1},{type:a.logic.type.set,regex:/^set\s+([a-zA-Z0-9_,\s]+)\s*=\s*(.+)$/,next:[],open:!0,compile:function(b){var c=b.match[1].trim(),d=b.match[2],e=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:d}]).stack;return b.key=c,b.expression=e,delete b.match,b},parse:function(b,c,d){var e=a.expression.parse.apply(this,[b.expression,c]),f=b.key;return this.context[f]=e,c[f]=e,{chain:d,context:c}}},{type:a.logic.type.filter,regex:/^filter\s+(.+)$/,next:[a.logic.type.endfilter],open:!0,compile:function(b){var c="|"+b.match[1].trim();return b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:c}]).stack,delete b.match,b},parse:function(b,c,d){var e=a.parse.apply(this,[b.output,c]),f=[{type:a.expression.type.string,value:e}].concat(b.stack),g=a.expression.parse.apply(this,[f,c]);return{chain:d,output:g}}},{type:a.logic.type.endfilter,regex:/^endfilter$/,next:[],open:!1},{type:a.logic.type.block,regex:/^block\s+([a-zA-Z0-9_]+)$/,next:[a.logic.type.endblock],open:!0,compile:function(a){return a.block=a.match[1].trim(),delete a.match,a},parse:function(b,c,d){var e="",f="",g=this.blocks[b.block]&&this.blocks[b.block].indexOf(a.placeholders.parent)>-1;if(this.blocks[b.block]===undefined||g)e=a.expression.parse.apply(this,[{type:a.expression.type.string,value:a.parse.apply(this,[b.output,c])},c]),g?this.blocks[b.block]=this.blocks[b.block].replace(a.placeholders.parent,e):this.blocks[b.block]=e;return this.extend===null&&(this.child.blocks[b.block]?f=this.child.blocks[b.block]:f=this.blocks[b.block]),{chain:d,output:f}}},{type:a.logic.type.endblock,regex:/^endblock$/,next:[],open:!1},{type:a.logic.type.extends_,regex:/^extends\s+(.+)$/,next:[],open:!0,compile:function(b){var c=b.match[1].trim();return delete b.match,b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:c}]).stack,b},parse:function(b,c,d){var e=a.expression.parse.apply(this,[b.stack,c]);return this.extend=e,{chain:d,output:""}}},{type:a.logic.type.use,regex:/^use\s+(.+)$/,next:[],open:!0,compile:function(b){var c=b.match[1].trim();return delete b.match,b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:c}]).stack,b},parse:function(b,c,d){var e=a.expression.parse.apply(this,[b.stack,c]);return this.importBlocks(e),{chain:d,output:""}}},{type:a.logic.type.include,regex:/^include\s+(ignore missing\s+)?(.+?)\s*(?:with\s+(.+?))?\s*(only)?$/,next:[],open:!0,compile:function(b){var c=b.match,d=c[1]!==undefined,e=c[2].trim(),f=c[3],g=c[4]!==undefined;return delete b.match,b.only=g,b.includeMissing=d,b.stack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:e}]).stack,f!==undefined&&(b.withStack=a.expression.compile.apply(this,[{type:a.expression.type.expression,value:f.trim()}]).stack),b},parse:function(b,c,d){var e={},f,g,h;if(!b.only)for(g in c)c.hasOwnProperty(g)&&(e[g]=c[g]);if(b.withStack!==undefined){f=a.expression.parse.apply(this,[b.withStack,c]);for(g in f)f.hasOwnProperty(g)&&(e[g]=f[g])}var i=a.expression.parse.apply(this,[b.stack,e]);return h=this.importFile(i),{chain:d,output:h.render(e)}}}],a.logic.handler={},a.logic.extendType=function(b,c){c=c||"Twig.logic.type"+b,a.logic.type[b]=c},a.logic.extend=function(b){if(!b.type)throw new a.Error("Unable to extend logic definition. No type provided for "+b);if(a.logic.type[b.type])throw new a.Error("Unable to extend logic definitions. Type "+b.type+" is already defined.");a.logic.extendType(b.type),a.logic.handler[b.type]=b};while(a.logic.definitions.length>0)a.logic.extend(a.logic.definitions.shift());return a.logic.compile=function(b){var c=b.value.trim(),d=a.logic.tokenize.apply(this,[c]),e=a.logic.handler[d.type];return e.compile&&(d=e.compile.apply(this,[d]),a.log.trace("Twig.logic.compile: ","Compiled logic token to ",d)),d},a.logic.tokenize=function(b){var c={},d=null,e=null,f=null,g=null,h=null,i=null;b=b.trim();for(d in a.logic.handler)if(a.logic.handler.hasOwnProperty(d)){e=a.logic.handler[d].type,f=a.logic.handler[d].regex,g=[],f instanceof Array?g=f:g.push(f);while(g.length>0){h=g.shift(),i=h.exec(b.trim());if(i!==null)return c.type=e,c.match=i,a.log.trace("Twig.logic.tokenize: ","Matched a ",e," regular expression of ",i),c}}throw new a.Error("Unable to parse '"+b.trim()+"'")},a.logic.parse=function(b,c,d){var e="",f;return c=c||{},a.log.debug("Twig.logic.parse: ","Parsing logic token ",b),f=a.logic.handler[b.type],f.parse&&(e=f.parse.apply(this,[b,c,d])),e},a}(Twig||{}),Twig=function(a){"use strict",a.expression={},a.expression.reservedWords=["true","false","null"],a.expression.type={comma:"Twig.expression.type.comma",expression:"Twig.expression.type.expression",operator:{unary:"Twig.expression.type.operator.unary",binary:"Twig.expression.type.operator.binary"},string:"Twig.expression.type.string",bool:"Twig.expression.type.bool",array:{start:"Twig.expression.type.array.start",end:"Twig.expression.type.array.end"},object:{start:"Twig.expression.type.object.start",end:"Twig.expression.type.object.end"},parameter:{start:"Twig.expression.type.parameter.start",end:"Twig.expression.type.parameter.end"},key:{period:"Twig.expression.type.key.period",brackets:"Twig.expression.type.key.brackets"},filter:"Twig.expression.type.filter",_function:"Twig.expression.type._function",variable:"Twig.expression.type.variable",number:"Twig.expression.type.number",_null:"Twig.expression.type.null",test:"Twig.expression.type.test"},a.expression.set={operations:[a.expression.type.filter,a.expression.type.operator.unary,a.expression.type.operator.binary,a.expression.type.array.end,a.expression.type.object.end,a.expression.type.parameter.end,a.expression.type.comma,a.expression.type.test],expressions:[a.expression.type._function,a.expression.type.expression,a.expression.type.bool,a.expression.type.string,a.expression.type.variable,a.expression.type.number,a.expression.type._null,a.expression.type.array.start,a.expression.type.object.start]},a.expression.set.operations_extended=a.expression.set.operations.concat([a.expression.type.key.period,a.expression.type.key.brackets]),a.expression.fn={compile:{push:function(a,b,c){c.push(a)},push_both:function(a,b,c){c.push(a),b.push(a)}},parse:{push:function(a,b,c){b.push(a)},push_value:function(a,b,c){b.push(a.value)}}},a.expression.definitions=[{type:a.expression.type.test,regex:/^is\s+(not)?\s*([a-zA-Z_][a-zA-Z0-9_]*)/,next:a.expression.set.operations.concat([a.expression.type.parameter.start]),compile:function(a,b,c){a.filter=a.match[2],a.modifier=a.match[1],delete a.match,delete a.value,c.push(a)},parse:function(b,c,d){var e=c.pop(),f=b.params&&a.expression.parse.apply(this,[b.params,d]),g=a.test(b.filter,e,f);b.modifier=="not"?c.push(!g):c.push(g)}},{type:a.expression.type.comma,regex:/^,/,next:a.expression.set.expressions,compile:function(b,c,d){var e=c.length-1,f;delete b.match,delete b.value;for(;e>=0;e--){f=c.pop();if(f.type===a.expression.type.object.start||f.type===a.expression.type.parameter.start||f.type===a.expression.type.array.start){c.push(f);break}d.push(f)}d.push(b)}},{type:a.expression.type.expression,regex:/^\(([^\)]+)\)/,next:a.expression.set.operations_extended,compile:function(b,c,d){b.value=b.match[1];var e=a.expression.compile(b).stack;while(e.length>0)d.push(e.shift())}},{type:a.expression.type.operator.binary,regex:/(^[\+\-~%\?\:]|^[!=]==?|^[!<>]=?|^\*\*?|^\/\/?|^and\s+|^or\s+|^in\s+|^not in\s+|^\.\.)/,next:a.expression.set.expressions.concat([a.expression.type.operator.unary]),compile:function(b,c,d){delete b.match,b.value=b.value.trim();var e=b.value,f=a.expression.operator.lookup(e,b);a.log.trace("Twig.expression.compile: ","Operator: ",f," from ",e);while(c.length>0&&(c[c.length-1].type==a.expression.type.operator.unary||c[c.length-1].type==a.expression.type.operator.binary)&&(f.associativity===a.expression.operator.leftToRight&&f.precidence>=c[c.length-1].precidence||f.associativity===a.expression.operator.rightToLeft&&f.precidence>c[c.length-1].precidence)){var g=c.pop();d.push(g)}if(e===":"){if(!c[c.length-1]||c[c.length-1].value!=="?"){var h=d.pop();if(h.type!==a.expression.type.string&&h.type!==a.expression.type.variable&&h.type!==a.expression.type.number)throw new a.Error("Unexpected value before ':' of "+h.type+" = "+h.value);b.key=h.value,d.push(b);return}}else c.push(f)},parse:function(b,c,d){b.key?c.push(b):a.expression.operator.parse(b.value,c)}},{type:a.expression.type.operator.unary,regex:/(^not\s+)/,next:a.expression.set.expressions,compile:function(b,c,d){delete b.match,b.value=b.value.trim();var e=b.value,f=a.expression.operator.lookup(e,b);a.log.trace("Twig.expression.compile: ","Operator: ",f," from ",e);while(c.length>0&&(c[c.length-1].type==a.expression.type.operator.unary||c[c.length-1].type==a.expression.type.operator.binary)&&(f.associativity===a.expression.operator.leftToRight&&f.precidence>=c[c.length-1].precidence||f.associativity===a.expression.operator.rightToLeft&&f.precidence>c[c.length-1].precidence)){var g=c.pop();d.push(g)}c.push(f)},parse:function(b,c,d){a.expression.operator.parse(b.value,c)}},{type:a.expression.type.string,regex:/^(["'])(?:(?=(\\?))\2.)*?\1/,next:a.expression.set.operations,compile:function(b,c,d){var e=b.value;delete b.match,e.substring(0,1)==='"'?e=e.replace('\\"','"'):e=e.replace("\\'","'"),b.value=e.substring(1,e.length-1),a.log.trace("Twig.expression.compile: ","String value: ",b.value),d.push(b)},parse:a.expression.fn.parse.push_value},{type:a.expression.type.parameter.start,regex:/^\(/,next:a.expression.set.expressions.concat([a.expression.type.parameter.end]),compile:a.expression.fn.compile.push_both,parse:a.expression.fn.parse.push},{type:a.expression.type.parameter.end,regex:/^\)/,next:a.expression.set.operations_extended,compile:function(b,c,d){var e;e=c.pop();while(c.length>0&&e.type!=a.expression.type.parameter.start)d.push(e),e=c.pop();var f=[];while(b.type!==a.expression.type.parameter.start)f.unshift(b),b=d.pop();f.unshift(b),b=d.pop();if(b.type!==a.expression.type._function&&b.type!==a.expression.type.filter&&b.type!==a.expression.type.test&&b.type!==a.expression.type.key.brackets&&b.type!==a.expression.type.key.period)throw new a.Error("Expected filter or function before parameters, got "+b.type);b.params=f,d.push(b)},parse:function(b,c,d){var e=[],f=!1,g=null;while(c.length>0){g=c.pop();if(g&&g.type&&g.type==a.expression.type.parameter.start){f=!0;break}e.unshift(g)}if(!f)throw new a.Error("Expected end of parameter set.");c.push(e)}},{type:a.expression.type.array.start,regex:/^\[/,next:a.expression.set.expressions.concat([a.expression.type.array.end]),compile:a.expression.fn.compile.push_both,parse:a.expression.fn.parse.push},{type:a.expression.type.array.end,regex:/^\]/,next:a.expression.set.operations_extended,compile:function(b,c,d){var e=c.length-1,f;for(;e>=0;e--){f=c.pop();if(f.type===a.expression.type.array.start)break;d.push(f)}d.push(b)},parse:function(b,c,d){var e=[],f=!1,g=null;while(c.length>0){g=c.pop();if(g.type&&g.type==a.expression.type.array.start){f=!0;break}e.unshift(g)}if(!f)throw new a.Error("Expected end of array.");c.push(e)}},{type:a.expression.type.object.start,regex:/^\{/,next:a.expression.set.expressions.concat([a.expression.type.object.end]),compile:a.expression.fn.compile.push_both,parse:a.expression.fn.parse.push},{type:a.expression.type.object.end,regex:/^\}/,next:a.expression.set.operations_extended,compile:function(b,c,d){var e=c.length-1,f;for(;e>=0;e--){f=c.pop();if(f&&f.type===a.expression.type.object.start)break;d.push(f)}d.push(b)},parse:function(b,c,d){var e={},f=!1,g=null,h=null,i=!1,j=null;while(c.length>0){g=c.pop();if(g&&g.type&&g.type===a.expression.type.object.start){f=!0;break}if(g&&g.type&&(g.type===a.expression.type.operator.binary||g.type===a.expression.type.operator.unary)&&g.key){if(!i)throw new a.Error("Missing value for key '"+g.key+"' in object definition.");e[g.key]=j,e._keys===undefined&&(e._keys=[]),e._keys.unshift(g.key),j=null,i=!1}else i=!0,j=g}if(!f)throw new a.Error("Unexpected end of object.");c.push(e)}},{type:a.expression.type.filter,regex:/^\|\s?([a-zA-Z_][a-zA-Z0-9_\-]*)/,next:a.expression.set.operations_extended.concat([a.expression.type.parameter.start]),compile:function(a,b,c){a.value=a.match[1],c.push(a)},parse:function(b,c,d){var e=c.pop(),f=b.params&&a.expression.parse.apply(this,[b.params,d]);c.push(a.filter.apply(this,[b.value,e,f]))}},{type:a.expression.type._function,regex:/^([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/,next:a.expression.type.parameter.start,transform:function(a,b){return"("},compile:function(a,b,c){var d=a.match[1];a.fn=d,delete a.match,delete a.value,c.push(a)},parse:function(b,c,d){var e=b.params&&a.expression.parse.apply(this,[b.params,d]),f=b.fn,g;if(a.functions[f])g=a.functions[f].apply(this,e);else{if(typeof d[f]!="function")throw new a.Error(f+" function does not exist and is not defined in the context");g=d[f].apply(d,e)}c.push(g)}},{type:a.expression.type.variable,regex:/^[a-zA-Z_][a-zA-Z0-9_]*/,next:a.expression.set.operations_extended.concat([a.expression.type.parameter.start]),compile:a.expression.fn.compile.push,validate:function(b,c){return a.expression.reservedWords.indexOf(b[0])==-1},parse:function(b,c,d){var e=a.expression.resolve(d[b.value],d);c.push(e)}},{type:a.expression.type.key.period,regex:/^\.([a-zA-Z0-9_]+)/,next:a.expression.set.operations_extended.concat([a.expression.type.parameter.start]),compile:function(a,b,c){a.key=a.match[1],delete a.match,delete a.value,c.push(a)},parse:function(b,c,d){var e=b.params&&a.expression.parse.apply(this,[b.params,d]),f=b.key,g=c.pop(),h;if(g===null||g===undefined){if(this.options.strict_variables)throw new a.Error("Can't access a key "+f+" on an null or undefined object.");return null}var i=function(a){return a.substr(0,1).toUpperCase()+a.substr
(1)};typeof g=="object"&&f in g?h=g[f]:g["get"+i(f)]!==undefined?h=g["get"+i(f)]:g["is"+i(f)]!==undefined?h=g["is"+i(f)]:h=null,c.push(a.expression.resolve(h,g,e))}},{type:a.expression.type.key.brackets,regex:/^\[([^\]]*)\]/,next:a.expression.set.operations_extended.concat([a.expression.type.parameter.start]),compile:function(b,c,d){var e=b.match[1];delete b.value,delete b.match,b.stack=a.expression.compile({value:e}).stack,d.push(b)},parse:function(b,c,d){var e=b.params&&a.expression.parse.apply(this,[b.params,d]),f=a.expression.parse.apply(this,[b.stack,d]),g=c.pop(),h;if(g===null||g===undefined){if(this.options.strict_variables)throw new a.Error("Can't access a key "+f+" on an null or undefined object.");return null}typeof g=="object"&&f in g?h=g[f]:h=null,c.push(a.expression.resolve(h,g,e))}},{type:a.expression.type._null,regex:/^null/,next:a.expression.set.operations,compile:function(a,b,c){delete a.match,a.value=null,c.push(a)},parse:a.expression.fn.parse.push_value},{type:a.expression.type.number,regex:/^\-?\d+(\.\d+)?/,next:a.expression.set.operations,compile:function(a,b,c){a.value=Number(a.value),c.push(a)},parse:a.expression.fn.parse.push_value},{type:a.expression.type.bool,regex:/^(true|false)/,next:a.expression.set.operations,compile:function(a,b,c){a.value=a.match[0]=="true",delete a.match,c.push(a)},parse:a.expression.fn.parse.push_value}],a.expression.resolve=function(a,b,c){return typeof a=="function"?a.apply(b,c||[]):a},a.expression.handler={},a.expression.extendType=function(b){a.expression.type[b]="Twig.expression.type."+b},a.expression.extend=function(b){if(!b.type)throw new a.Error("Unable to extend logic definition. No type provided for "+b);a.expression.handler[b.type]=b};while(a.expression.definitions.length>0)a.expression.extend(a.expression.definitions.shift());return a.expression.tokenize=function(b){var c=[],d=0,e=null,f,g,h,i,j,k=[],l;l=function(){var b=Array.prototype.slice.apply(arguments),g=b.pop(),h=b.pop();return a.log.trace("Twig.expression.tokenize","Matched a ",f," regular expression of ",b),e&&e.indexOf(f)<0?(k.push(f+" cannot follow a "+c[c.length-1].type+" at template:"+d+" near '"+b[0].substring(0,20)+"...'"),b[0]):a.expression.handler[f].validate&&!a.expression.handler[f].validate(b,c)?b[0]:(k=[],c.push({type:f,value:b[0],match:b}),j=!0,e=i,d+=b[0].length,a.expression.handler[f].transform?a.expression.handler[f].transform(b,c):"")},a.log.debug("Twig.expression.tokenize","Tokenizing expression ",b);while(b.length>0){b=b.trim();for(f in a.expression.handler)if(a.expression.handler.hasOwnProperty(f)){i=a.expression.handler[f].next,g=a.expression.handler[f].regex,g instanceof Array?h=g:h=[g],j=!1;while(h.length>0)g=h.pop(),b=b.replace(g,l);if(j)break}if(!j)throw k.length>0?new a.Error(k.join(" OR ")):new a.Error("Unable to parse '"+b+"' at template position"+d)}return a.log.trace("Twig.expression.tokenize","Tokenized to ",c),c},a.expression.compile=function(b){var c=b.value,d=a.expression.tokenize(c),e=null,f=[],g=[],h=null;a.log.trace("Twig.expression.compile: ","Compiling ",c);while(d.length>0)e=d.shift(),h=a.expression.handler[e.type],a.log.trace("Twig.expression.compile: ","Compiling ",e),h.compile&&h.compile(e,g,f),a.log.trace("Twig.expression.compile: ","Stack is",g),a.log.trace("Twig.expression.compile: ","Output is",f);while(g.length>0)f.push(g.pop());return a.log.trace("Twig.expression.compile: ","Final output is",f),b.stack=f,delete b.value,b},a.expression.parse=function(b,c){var d=this;b instanceof Array||(b=[b]);var e=[],f=null;return b.forEach(function(b){f=a.expression.handler[b.type],f.parse&&f.parse.apply(d,[b,e,c])}),e.pop()},a}(Twig||{}),Twig=function(a){"use strict",a.expression.operator={leftToRight:"leftToRight",rightToLeft:"rightToLeft"},a.expression.operator.lookup=function(b,c){switch(b){case"..":case"not in":case"in":c.precidence=20,c.associativity=a.expression.operator.leftToRight;break;case",":c.precidence=18,c.associativity=a.expression.operator.leftToRight;break;case"?":case":":c.precidence=16,c.associativity=a.expression.operator.rightToLeft;break;case"or":c.precidence=14,c.associativity=a.expression.operator.leftToRight;break;case"and":c.precidence=13,c.associativity=a.expression.operator.leftToRight;break;case"==":case"!=":c.precidence=9,c.associativity=a.expression.operator.leftToRight;break;case"<":case"<=":case">":case">=":c.precidence=8,c.associativity=a.expression.operator.leftToRight;break;case"~":case"+":case"-":c.precidence=6,c.associativity=a.expression.operator.leftToRight;break;case"//":case"**":case"*":case"/":case"%":c.precidence=5,c.associativity=a.expression.operator.leftToRight;break;case"not":c.precidence=3,c.associativity=a.expression.operator.rightToLeft;break;default:throw new a.Error(b+" is an unknown operator.")}return c.operator=b,c},a.expression.operator.parse=function(c,d){a.log.trace("Twig.expression.operator.parse: ","Handling ",c);var e,f,g;switch(c){case":":break;case"?":g=d.pop(),f=d.pop(),e=d.pop(),e?d.push(f):d.push(g);break;case"+":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(e+f);break;case"-":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(e-f);break;case"*":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(e*f);break;case"/":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(e/f);break;case"//":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(parseInt(e/f));break;case"%":f=parseFloat(d.pop()),e=parseFloat(d.pop()),d.push(e%f);break;case"~":f=d.pop(),e=d.pop(),d.push((e!==undefined?e.toString():"")+(f!==undefined?f.toString():""));break;case"not":case"!":d.push(!d.pop());break;case"<":f=d.pop(),e=d.pop(),d.push(e<f);break;case"<=":f=d.pop(),e=d.pop(),d.push(e<=f);break;case">":f=d.pop(),e=d.pop(),d.push(e>f);break;case">=":f=d.pop(),e=d.pop(),d.push(e>=f);break;case"===":f=d.pop(),e=d.pop(),d.push(e===f);break;case"==":f=d.pop(),e=d.pop(),d.push(e==f);break;case"!==":f=d.pop(),e=d.pop(),d.push(e!==f);break;case"!=":f=d.pop(),e=d.pop(),d.push(e!=f);break;case"or":f=d.pop(),e=d.pop(),d.push(e||f);break;case"and":f=d.pop(),e=d.pop(),d.push(e&&f);break;case"**":f=d.pop(),e=d.pop(),d.push(Math.pow(e,f));break;case"not in":f=d.pop(),e=d.pop(),d.push(!b(e,f));break;case"in":f=d.pop(),e=d.pop(),d.push(b(e,f));break;case"..":f=d.pop(),e=d.pop(),d.push(a.functions.range(e,f));break;default:throw new a.Error(c+" is an unknown operator.")}};var b=function(a,b){if(b.indexOf!=undefined)return b.indexOf(a)>-1;var c;for(c in b)if(b.hasOwnProperty(c)&&b[c]===a)return!0;return!1};return a}(Twig||{}),Twig=function(a){function b(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return b!==undefined&&b!==null&&c===a}return a.filters={upper:function(a){return a.toUpperCase()},lower:function(a){return a.toLowerCase()},capitalize:function(a){return a.substr(0,1).toUpperCase()+a.substr(1)},title:function(a){return a.replace(/(^|\s)([a-z])/g,function(a,b,c){return b+c.toUpperCase()})},length:function(a){if(a instanceof Array||typeof a=="string")return a.length;if(a instanceof Object)return a._keys===undefined?Object.keys(a).length:a._keys.length},reverse:function(a){if(b("Array",a))return a.reverse();if(b("String",a))return a.split("").reverse().join("");var c=a._keys||Object.keys(a).reverse();return a._keys=c,a},sort:function(a){if(b("Array",a))return a.sort();if(a instanceof Object){delete a._keys;var c=Object.keys(a),d=c.sort(function(b,c){return a[b]>a[c]});return a._keys=d,a}},keys:function(a){var b=a._keys||Object.keys(a),c=[];return b.forEach(function(b){if(b==="_keys")return;a.hasOwnProperty(b)&&c.push(b)}),c},url_encode:function(a){return encodeURIComponent(a)},join:function(a,b){var c="",d=[],e=null;return b&&b[0]&&(c=b[0]),a instanceof Array?d=a:(e=a._keys||Object.keys(a),e.forEach(function(b){if(b==="_keys")return;a.hasOwnProperty(b)&&d.push(a[b])})),d.join(c)},"default":function(b,c){if(c===undefined||c.length!==1)throw new a.Error("default filter expects one argument");return b===undefined||b===null||b===""?c[0]:b},json_encode:function(a){return delete a._keys,JSON.stringify(a)},merge:function(b,c){var d=[],e=0,f=[];b instanceof Array?c.forEach(function(a){a instanceof Array||(d={})}):d={},d instanceof Array||(d._keys=[]),b instanceof Array?b.forEach(function(a){d._keys&&d._keys.unshift(e),d[e]=a,e++}):(f=b._keys||Object.keys(b),f.forEach(function(a){d[a]=b[a],d._keys.push(a);var c=parseInt(a,10);!isNaN(c)&&c>=e&&(e=c+1)})),c.forEach(function(a){a instanceof Array?a.forEach(function(a){d._keys&&d._keys.push(e),d[e]=a,e++}):(f=a._keys||Object.keys(a),f.forEach(function(b){d[b]||d._keys.unshift(b),d[b]=a[b];var c=parseInt(b,10);!isNaN(c)&&c>=e&&(e=c+1)}))});if(c.length===0)throw new a.Error("Filter merge expects at least one parameter");return d},date:function(b,c){var d=a.functions.date(b);return a.lib.formatDate(d,c[0])},replace:function(a,b){var c=b[0],d;for(d in c)c.hasOwnProperty(d)&&d!=="_keys"&&(a=a.replace(d,c[d]));return a},format:function(b,c){return a.lib.vsprintf(b,c)},striptags:function(b){return a.lib.strip_tags(b)},escape:function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")},e:function(b){return a.filters.escape(b)},nl2br:function(b){var c="<br />";return a.filters.escape(b).replace(/\r\n/g,c).replace(/\r/g,c).replace(/\n/g,c)},number_format:function(a,b){var c=a,d=b&&b[0]?b[0]:undefined,e=b&&b[1]!==undefined?b[1]:".",f=b&&b[2]!==undefined?b[2]:",";c=(c+"").replace(/[^0-9+\-Ee.]/g,"");var g=isFinite(+c)?+c:0,h=isFinite(+d)?Math.abs(d):0,i="",j=function(a,b){var c=Math.pow(10,b);return""+Math.round(a*c)/c};return i=(h?j(g,h):""+Math.round(g)).split("."),i[0].length>3&&(i[0]=i[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,f)),(i[1]||"").length<h&&(i[1]=i[1]||"",i[1]+=(new Array(h-i[1].length+1)).join("0")),i.join(e)},trim:function(a,b){var c=a,d=" \n\r \f             ​\u2028\u2029 ";for(var e=0;e<c.length;e++)if(d.indexOf(c.charAt(e))===-1){c=c.substring(e);break}for(e=c.length-1;e>=0;e--)if(d.indexOf(c.charAt(e))===-1){c=c.substring(0,e+1);break}return d.indexOf(c.charAt(0))===-1?c:""}},a.filter=function(b,c,d){if(!a.filters[b])throw"Unable to find filter "+b;return a.filters[b].apply(this,[c,d])},a.filter.extend=function(b,c){a.filters[b]=c},a}(Twig||{}),Twig=function(a){function b(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return b!==undefined&&b!==null&&c===a}return a.functions={range:function(a,b,c){var d=[],e,f,g,h=c||1,i=!1;!isNaN(a)&&!isNaN(b)?(e=parseInt(a,10),f=parseInt(b,10)):isNaN(a)&&isNaN(b)?(i=!0,e=a.charCodeAt(0),f=b.charCodeAt(0)):(e=isNaN(a)?0:a,f=isNaN(b)?0:b),g=e>f?!1:!0;if(g)while(e<=f)d.push(i?String.fromCharCode(e):e),e+=h;else while(e>=f)d.push(i?String.fromCharCode(e):e),e-=h;return d},cycle:function(a,b){var c=b%a.length;return a[c]},dump:function(){var a="\n",b=" ",c=0,d="",e=Array.prototype.slice.call(arguments),f=function(a){var c="";while(a>0)a--,c+=b;return c},g=function(b){d+=f(c),typeof b=="object"?h(b):typeof b=="function"?d+="function()"+a:typeof b=="string"?d+="string("+b.length+') "'+b+'"'+a:typeof b=="number"?d+="number("+b+")"+a:typeof b=="boolean"&&(d+="bool("+b+")"+a)},h=function(b){var e;if(b===null)d+="NULL"+a;else if(b===undefined)d+="undefined"+a;else if(typeof b=="object"){d+=f(c)+typeof b,c++,d+="("+function(a){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(b)+") {"+a;for(e in b)d+=f(c)+"["+e+"]=> "+a,g(b[e]);c--,d+=f(c)+"}"+a}else g(b)};return e.length==0&&e.push(this.context),e.forEach(function(a){h(a)}),d},date:function(b,c){var d;if(b==undefined)d=new Date;else if(a.lib.is("Date",b))d=b;else if(a.lib.is("String",b))d=new Date(a.lib.strtotime(b)*1e3);else{if(!a.lib.is("Number",b))throw new a.Error("Unable to parse date "+b);d=new Date(b*1e3)}return d},parent:function(){return a.placeholders.parent}},a._function=function(b,c,d){if(!a.functions[b])throw"Unable to find function "+b;return a.functions[b](c,d)},a._function.extend=function(b,c){a.functions[b]=c},a}(Twig||{}),Twig=function(a){return"use strict",a.tests={empty:function(a){if(a===null||a===undefined)return!0;if(typeof a=="number")return!1;if(a.length&&a.length>0)return!1;for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},odd:function(a){return a%2===1},even:function(a){return a%2===0},divisibleby:function(a,b){return a%b[0]===0},defined:function(a){return a!==undefined},none:function(a){return a===null},"null":function(a){return this.none(a)},sameas:function(a,b){return a===b[0]}},a.test=function(b,c,d){if(!a.tests[b])throw"Test "+b+" is not defined.";return a.tests[b](c,d)},a.test.extend=function(b,c){a.tests[b]=c},a}(Twig||{}),Twig=function(a){return"use strict",a.exports={},a.exports.twig=function(c){"use strict";var d=c.id,e={strict_variables:c.strict_variables||!1};d&&a.validateId(d),c.debug!==undefined&&(a.debug=c.debug),c.trace!==undefined&&(a.trace=c.trace);if(c.data!==undefined)return new a.Template({data:c.data,module:c.module,id:d,options:e});if(c.ref!==undefined){if(c.id!==undefined)throw new Error("Both ref and id cannot be set on a twig.js template.");return a.Templates.load(c.ref)}if(c.href!==undefined)return a.Templates.loadRemote(c.href,{id:d,module:c.module,precompiled:c.precompiled,method:"ajax",async:c.async,options:e},c.load,c.error);if(c.path!==undefined)return a.Templates.loadRemote(c.path,{id:d,module:c.module,precompiled:c.precompiled,method:"fs",async:c.async,options:e},c.load,c.error)},a.exports.extendFilter=function(b,c){a.filter.extend(b,c)},a.exports.extendFunction=function(b,c){a._function.extend(b,c)},a.exports.extendTest=function(b,c){a.test.extend(b,c)},a.exports.extendTag=function(b){a.logic.extend(b)},a.exports.compile=function(b,c){var d=c.filename,e="/",f=c.filename,g;return g=new a.Template({data:b,path:f,id:d,options:c.settings["twig options"]}),function(a){return g.render(a)}},a.exports.renderFile=function(b,c,d){"function"==typeof c&&(d=c,c={});var e=c.settings["twig options"],f,g={path:b,load:function(a){d(null,a.render(c))}};if(e)for(f in e)g[f]=e[f];a.exports.twig(g)},a.exports.__express=a.exports.renderFile,a.exports.cache=function(b){a.cache=b},a}(Twig||{}),Twig=function(a){return a.compiler={module:{}},a.compiler.compile=function(b,c){var d=JSON.stringify(b.tokens),e=b.id,f;if(c.module){if(a.compiler.module[c.module]===undefined)throw new a.Error("Unable to find module type "+c.module);f=a.compiler.module[c.module](e,d,c.twig)}else f=a.compiler.wrap(e,d);return f},a.compiler.module={amd:function(b,c,d){return'define(["'+d+'"], function (Twig) {\n var twig = Twig.twig;\n'+a.compiler.wrap(b,c)+"\n return templates;\n});"},node:function(b,c){return'var twig = require("twig").twig;\nexports.template = '+a.compiler.wrap(b,c)},cjs2:function(b,c,d){return'module.declare([{ twig: "'+d+'" }], function (require, exports, module) {\n'+' var twig = require("twig").twig;\n'+" exports.template = "+a.compiler.wrap(b,c)+"\n});"}},a.compiler.wrap=function(a,b){return'twig({id:"'+a.replace('"','\\"')+'", data:'+b+", precompiled: true});\n"},a}(Twig||{});typeof module!="undefined"&&module.declare?module.declare([],function(a,b,c){for(key in Twig.exports)Twig.exports.hasOwnProperty(key)&&(b[key]=Twig.exports[key])}):typeof module!="undefined"&&module.exports?module.exports=Twig.exports:(window.twig=Twig.exports.twig,window.Twig=Twig.exports);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc