From 66870eb28f13ead62927bfcb3bb2c24afc1860a8 Mon Sep 17 00:00:00 2001 From: Jon Buckley Date: Thu, 1 May 2014 17:50:10 -0700 Subject: [PATCH] 1.0.5 --- bower.json | 2 +- browser/nunjucks-slim.js | 2 +- browser/nunjucks-slim.min.js | 4 ++-- browser/nunjucks.js | 2 +- browser/nunjucks.min.js | 4 ++-- package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index b5418f10..5c8789cc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "nunjucks", - "version": "1.0.1", + "version": "1.0.5", "main": "browser/nunjucks.min.js", "ignore": [ "Makefile", diff --git a/browser/nunjucks-slim.js b/browser/nunjucks-slim.js index 7cdd2884..d7b3cd41 100644 --- a/browser/nunjucks-slim.js +++ b/browser/nunjucks-slim.js @@ -1,4 +1,4 @@ -// Browser bundle of nunjucks 1.0.4 (slim, only works with precompiled templates) +// Browser bundle of nunjucks 1.0.5 (slim, only works with precompiled templates) (function() { var modules = {}; diff --git a/browser/nunjucks-slim.min.js b/browser/nunjucks-slim.min.js index 3b1b15b0..f9ad8ba4 100644 --- a/browser/nunjucks-slim.min.js +++ b/browser/nunjucks-slim.min.js @@ -1,3 +1,3 @@ -// Browser bundle of nunjucks 1.0.4 (slim, only works with precompiled templates) +// Browser bundle of nunjucks 1.0.5 (slim, only works with precompiled templates) -(function(){var modules={};(function(){function extend(cls,name,props){var F=function(){};F.prototype=cls.prototype;var prototype=new F;var fnTest=/xyz/.test(function(){xyz})?/\bparent\b/:/.*/;props=props||{};for(var k in props){var src=props[k];var parent=prototype[k];if(typeof parent=="function"&&typeof src=="function"&&fnTest.test(src)){prototype[k]=function(src,parent){return function(){var tmp=this.parent;this.parent=parent;var res=src.apply(this,arguments);this.parent=tmp;return res}}(src,parent)}else{prototype[k]=src}}prototype.typename=name;var new_cls=function(){if(prototype.init){prototype.init.apply(this,arguments)}};new_cls.prototype=prototype;new_cls.prototype.constructor=new_cls;new_cls.extend=function(name,props){if(typeof name=="object"){props=name;name="anonymous"}return extend(new_cls,name,props)};return new_cls}modules["object"]=extend(Object,"Object",{})})();(function(){var ArrayProto=Array.prototype;var ObjProto=Object.prototype;var escapeMap={"&":"&",'"':""","'":"'","<":"<",">":">"};var escapeRegex=/[&"'<>]/g;var lookupEscape=function(ch){return escapeMap[ch]};var exports=modules["lib"]={};exports.withPrettyErrors=function(path,withInternals,func){try{return func()}catch(e){if(!e.Update){e=new exports.TemplateError(e)}e.Update(path);if(!withInternals){var old=e;e=new Error(old.message);e.name=old.name}throw e}};exports.TemplateError=function(message,lineno,colno){var err=this;if(message instanceof Error){err=message;message=message.name+": "+message.message}else{if(Error.captureStackTrace){Error.captureStackTrace(err)}}err.name="Template render error";err.message=message;err.lineno=lineno;err.colno=colno;err.firstUpdate=true;err.Update=function(path){var message="("+(path||"unknown path")+")";if(this.firstUpdate){if(this.lineno&&this.colno){message+=" [Line "+this.lineno+", Column "+this.colno+"]"}else if(this.lineno){message+=" [Line "+this.lineno+"]"}}message+="\n ";if(this.firstUpdate){message+=" "}this.message=message+(this.message||"");this.firstUpdate=false;return this};return err};exports.TemplateError.prototype=Error.prototype;exports.escape=function(val){return val.replace(escapeRegex,lookupEscape)};exports.isFunction=function(obj){return ObjProto.toString.call(obj)=="[object Function]"};exports.isArray=Array.isArray||function(obj){return ObjProto.toString.call(obj)=="[object Array]"};exports.isString=function(obj){return ObjProto.toString.call(obj)=="[object String]"};exports.isObject=function(obj){return ObjProto.toString.call(obj)=="[object Object]"};exports.groupBy=function(obj,val){var result={};var iterator=exports.isFunction(val)?val:function(obj){return obj[val]};for(var i=0;i>>0;if(len===0){return-1}var n=0;if(arguments.length>2){n=Number(arguments[2]);if(n!=n){n=0}else if(n!=0&&n!=Infinity&&n!=-Infinity){n=(n>0||-1)*Math.floor(Math.abs(n))}}if(n>=len){return-1}var k=n>=0?n:Math.max(len-Math.abs(n),0);for(;kargNames.length){args=Array.prototype.slice.call(arguments,0,argNames.length);var vals=Array.prototype.slice.call(arguments,args.length,argCount);for(var i=0;i=width){return str}var spaces=width-str.length;var pre=lib.repeat(" ",spaces/2-spaces%2);var post=lib.repeat(" ",spaces/2);return r.copySafeness(str,pre+str+post)},"default":function(val,def){return val?val:def},dictsort:function(val,case_sensitive,by){if(!lib.isObject(val)){throw new lib.TemplateError("dictsort filter: val must be an object")}var array=[];for(var k in val){array.push([k,val[k]])}var si;if(by===undefined||by==="key"){si=0}else if(by==="value"){si=1}else{throw new lib.TemplateError("dictsort filter: You can only sort by either key or value")}array.sort(function(t1,t2){var a=t1[si];var b=t2[si];if(!case_sensitive){if(lib.isString(a)){a=a.toUpperCase()}if(lib.isString(b)){b=b.toUpperCase()}}return a>b?1:a==b?0:-1});return array},escape:function(str){if(typeof str=="string"||str instanceof r.SafeString){return lib.escape(str)}return str},safe:function(str){return r.markSafe(str)},first:function(arr){return arr[0]},groupby:function(arr,attr){return lib.groupBy(arr,attr)},indent:function(str,width,indentfirst){width=width||4;var res="";var lines=str.split("\n");var sp=lib.repeat(" ",width);for(var i=0;i=maxCount){break}last=res;res=res.replace(old,new_);count++}return r.copySafeness(str,res)},reverse:function(val){var arr;if(lib.isString(val)){arr=filters.list(val)}else{arr=lib.map(val,function(v){return v})}arr.reverse();if(lib.isString(val)){return r.copySafeness(val,arr.join(""))}return arr},round:function(val,precision,method){precision=precision||0;var factor=Math.pow(10,precision);var rounder;if(method=="ceil"){rounder=Math.ceil}else if(method=="floor"){rounder=Math.floor}else{rounder=Math.round}return rounder(val*factor)/factor},slice:function(arr,slices,fillWith){var sliceLength=Math.floor(arr.length/slices);var extra=arr.length%slices;var offset=0;var res=[];for(var i=0;i=extra){slice.push(fillWith)}res.push(slice)}return res},sort:function(arr,reverse,caseSens,attr){arr=lib.map(arr,function(v){return v});arr.sort(function(a,b){var x,y;if(attr){x=a[attr];y=b[attr]}else{x=a;y=b}if(!caseSens&&lib.isString(x)&&lib.isString(y)){x=x.toLowerCase();y=y.toLowerCase()}if(xy){return reverse?-1:1}else{return 0}});return arr},string:function(obj){return r.copySafeness(obj,obj)},title:function(str){var words=str.split(" ");for(var i=0;i"+possibleUrl.substr(0,length)+"";if(wwwRE.test(possibleUrl))return'"+possibleUrl.substr(0,length)+"";if(emailRE.test(possibleUrl))return''+possibleUrl+"";if(tldRE.test(possibleUrl))return'"+possibleUrl.substr(0,length)+"";return possibleUrl});return words.join(" ")},wordcount:function(str){var words=str?str.match(/\w+/g):null;return words?words.length:null},"float":function(val,def){var res=parseFloat(val);return isNaN(res)?def:res},"int":function(val,def){var res=parseInt(val,10);return isNaN(res)?def:res}};filters.d=filters["default"];filters.e=filters.escape;modules["filters"]=filters})();(function(){function cycler(items){var index=-1;var current=null;return{reset:function(){index=-1;current=null},next:function(){index++;if(index>=items.length){index=0}current=items[index];return current}}}function joiner(sep){sep=sep||",";var first=true;return function(){var val=first?"":sep;first=false;return val}}var globals={range:function(start,stop,step){if(!stop){stop=start;start=0;step=1}else if(!step){step=1}var arr=[];for(var i=start;i":">"};var escapeRegex=/[&"'<>]/g;var lookupEscape=function(ch){return escapeMap[ch]};var exports=modules["lib"]={};exports.withPrettyErrors=function(path,withInternals,func){try{return func()}catch(e){if(!e.Update){e=new exports.TemplateError(e)}e.Update(path);if(!withInternals){var old=e;e=new Error(old.message);e.name=old.name}throw e}};exports.TemplateError=function(message,lineno,colno){var err=this;if(message instanceof Error){err=message;message=message.name+": "+message.message}else{if(Error.captureStackTrace){Error.captureStackTrace(err)}}err.name="Template render error";err.message=message;err.lineno=lineno;err.colno=colno;err.firstUpdate=true;err.Update=function(path){var message="("+(path||"unknown path")+")";if(this.firstUpdate){if(this.lineno&&this.colno){message+=" [Line "+this.lineno+", Column "+this.colno+"]"}else if(this.lineno){message+=" [Line "+this.lineno+"]"}}message+="\n ";if(this.firstUpdate){message+=" "}this.message=message+(this.message||"");this.firstUpdate=false;return this};return err};exports.TemplateError.prototype=Error.prototype;exports.escape=function(val){return val.replace(escapeRegex,lookupEscape)};exports.isFunction=function(obj){return ObjProto.toString.call(obj)=="[object Function]"};exports.isArray=Array.isArray||function(obj){return ObjProto.toString.call(obj)=="[object Array]"};exports.isString=function(obj){return ObjProto.toString.call(obj)=="[object String]"};exports.isObject=function(obj){return ObjProto.toString.call(obj)=="[object Object]"};exports.groupBy=function(obj,val){var result={};var iterator=exports.isFunction(val)?val:function(obj){return obj[val]};for(var i=0;i>>0;if(len===0){return-1}var n=0;if(arguments.length>2){n=Number(arguments[2]);if(n!=n){n=0}else if(n!=0&&n!=Infinity&&n!=-Infinity){n=(n>0||-1)*Math.floor(Math.abs(n))}}if(n>=len){return-1}var k=n>=0?n:Math.max(len-Math.abs(n),0);for(;kargNames.length){args=Array.prototype.slice.call(arguments,0,argNames.length);var vals=Array.prototype.slice.call(arguments,args.length,argCount);for(var i=0;i=width){return str}var spaces=width-str.length;var pre=lib.repeat(" ",spaces/2-spaces%2);var post=lib.repeat(" ",spaces/2);return r.copySafeness(str,pre+str+post)},"default":function(val,def){return val?val:def},dictsort:function(val,case_sensitive,by){if(!lib.isObject(val)){throw new lib.TemplateError("dictsort filter: val must be an object")}var array=[];for(var k in val){array.push([k,val[k]])}var si;if(by===undefined||by==="key"){si=0}else if(by==="value"){si=1}else{throw new lib.TemplateError("dictsort filter: You can only sort by either key or value")}array.sort(function(t1,t2){var a=t1[si];var b=t2[si];if(!case_sensitive){if(lib.isString(a)){a=a.toUpperCase()}if(lib.isString(b)){b=b.toUpperCase()}}return a>b?1:a==b?0:-1});return array},escape:function(str){if(typeof str=="string"||str instanceof r.SafeString){return lib.escape(str)}return str},safe:function(str){return r.markSafe(str)},first:function(arr){return arr[0]},groupby:function(arr,attr){return lib.groupBy(arr,attr)},indent:function(str,width,indentfirst){width=width||4;var res="";var lines=str.split("\n");var sp=lib.repeat(" ",width);for(var i=0;i=maxCount){break}last=res;res=res.replace(old,new_);count++}return r.copySafeness(str,res)},reverse:function(val){var arr;if(lib.isString(val)){arr=filters.list(val)}else{arr=lib.map(val,function(v){return v})}arr.reverse();if(lib.isString(val)){return r.copySafeness(val,arr.join(""))}return arr},round:function(val,precision,method){precision=precision||0;var factor=Math.pow(10,precision);var rounder;if(method=="ceil"){rounder=Math.ceil}else if(method=="floor"){rounder=Math.floor}else{rounder=Math.round}return rounder(val*factor)/factor},slice:function(arr,slices,fillWith){var sliceLength=Math.floor(arr.length/slices);var extra=arr.length%slices;var offset=0;var res=[];for(var i=0;i=extra){slice.push(fillWith)}res.push(slice)}return res},sort:function(arr,reverse,caseSens,attr){arr=lib.map(arr,function(v){return v});arr.sort(function(a,b){var x,y;if(attr){x=a[attr];y=b[attr]}else{x=a;y=b}if(!caseSens&&lib.isString(x)&&lib.isString(y)){x=x.toLowerCase();y=y.toLowerCase()}if(xy){return reverse?-1:1}else{return 0}});return arr},string:function(obj){return r.copySafeness(obj,obj)},title:function(str){var words=str.split(" ");for(var i=0;i"+possibleUrl.substr(0,length)+"";if(wwwRE.test(possibleUrl))return'"+possibleUrl.substr(0,length)+"";if(emailRE.test(possibleUrl))return''+possibleUrl+"";if(tldRE.test(possibleUrl))return'"+possibleUrl.substr(0,length)+"";return possibleUrl});return words.join(" ")},wordcount:function(str){var words=str?str.match(/\w+/g):null;return words?words.length:null},"float":function(val,def){var res=parseFloat(val);return isNaN(res)?def:res},"int":function(val,def){var res=parseInt(val,10);return isNaN(res)?def:res}};filters.d=filters["default"];filters.e=filters.escape;modules["filters"]=filters})();(function(){function cycler(items){var index=-1;var current=null;return{reset:function(){index=-1;current=null},next:function(){index++;if(index>=items.length){index=0}current=items[index];return current}}}function joiner(sep){sep=sep||",";var first=true;return function(){var val=first?"":sep;first=false;return val}}var globals={range:function(start,stop,step){if(!stop){stop=start;start=0;step=1}else if(!step){step=1}var arr=[];for(var i=start;i":">"};var escapeRegex=/[&"'<>]/g;var lookupEscape=function(ch){return escapeMap[ch]};var exports=modules["lib"]={};exports.withPrettyErrors=function(path,withInternals,func){try{return func()}catch(e){if(!e.Update){e=new exports.TemplateError(e)}e.Update(path);if(!withInternals){var old=e;e=new Error(old.message);e.name=old.name}throw e}};exports.TemplateError=function(message,lineno,colno){var err=this;if(message instanceof Error){err=message;message=message.name+": "+message.message}else{if(Error.captureStackTrace){Error.captureStackTrace(err)}}err.name="Template render error";err.message=message;err.lineno=lineno;err.colno=colno;err.firstUpdate=true;err.Update=function(path){var message="("+(path||"unknown path")+")";if(this.firstUpdate){if(this.lineno&&this.colno){message+=" [Line "+this.lineno+", Column "+this.colno+"]"}else if(this.lineno){message+=" [Line "+this.lineno+"]"}}message+="\n ";if(this.firstUpdate){message+=" "}this.message=message+(this.message||"");this.firstUpdate=false;return this};return err};exports.TemplateError.prototype=Error.prototype;exports.escape=function(val){return val.replace(escapeRegex,lookupEscape)};exports.isFunction=function(obj){return ObjProto.toString.call(obj)=="[object Function]"};exports.isArray=Array.isArray||function(obj){return ObjProto.toString.call(obj)=="[object Array]"};exports.isString=function(obj){return ObjProto.toString.call(obj)=="[object String]"};exports.isObject=function(obj){return ObjProto.toString.call(obj)=="[object Object]"};exports.groupBy=function(obj,val){var result={};var iterator=exports.isFunction(val)?val:function(obj){return obj[val]};for(var i=0;i>>0;if(len===0){return-1}var n=0;if(arguments.length>2){n=Number(arguments[2]);if(n!=n){n=0}else if(n!=0&&n!=Infinity&&n!=-Infinity){n=(n>0||-1)*Math.floor(Math.abs(n))}}if(n>=len){return-1}var k=n>=0?n:Math.max(len-Math.abs(n),0);for(;k0||!inline){for(var j=0;jargNames.length){args=Array.prototype.slice.call(arguments,0,argNames.length);var vals=Array.prototype.slice.call(arguments,args.length,argCount);for(var i=0;i=","//","**"];var curComplex=cur+this.current();var type;if(complexOps.indexOf(curComplex)!==-1){this.forward();cur=curComplex}switch(cur){case"(":type=TOKEN_LEFT_PAREN;break;case")":type=TOKEN_RIGHT_PAREN;break;case"[":type=TOKEN_LEFT_BRACKET;break;case"]":type=TOKEN_RIGHT_BRACKET;break;case"{":type=TOKEN_LEFT_CURLY;break;case"}":type=TOKEN_RIGHT_CURLY;break;case",":type=TOKEN_COMMA;break;case":":type=TOKEN_COLON;break;case"|":type=TOKEN_PIPE;break;default:type=TOKEN_OPERATOR}return token(type,cur,lineno,colno)}else{tok=this._extractUntil(whitespaceChars+delimChars);if(tok.match(/^[-+]?[0-9]+$/)){if(this.current()=="."){this.forward();var dec=this._extract(intChars);return token(TOKEN_FLOAT,tok+"."+dec,lineno,colno)}else{return token(TOKEN_INT,tok,lineno,colno)}}else if(tok.match(/^(true|false)$/)){return token(TOKEN_BOOLEAN,tok,lineno,colno)}else if(tok){return token(TOKEN_SYMBOL,tok,lineno,colno)}else{throw new Error("Unexpected value while parsing: "+tok)}}}else{var beginChars=BLOCK_START.charAt(0)+VARIABLE_START.charAt(0)+COMMENT_START.charAt(0)+COMMENT_END.charAt(0);var tok;if(this.is_finished()){return null}else if((tok=this._extractString(BLOCK_START+"-"))||(tok=this._extractString(BLOCK_START))){this.in_code=true;return token(TOKEN_BLOCK_START,tok,lineno,colno)}else if(tok=this._extractString(VARIABLE_START)){this.in_code=true;return token(TOKEN_VARIABLE_START,tok,lineno,colno)}else{tok="";var data;var in_comment=false;if(this._matches(COMMENT_START)){in_comment=true;tok=this._extractString(COMMENT_START)}while((data=this._extractUntil(beginChars))!==null){tok+=data;if((this._matches(BLOCK_START)||this._matches(VARIABLE_START)||this._matches(COMMENT_START))&&!in_comment){break}else if(this._matches(COMMENT_END)){if(!in_comment){throw new Error("unexpected end of comment")}tok+=this._extractString(COMMENT_END);break}else{tok+=this.current();this.forward()}}if(data===null&&in_comment){throw new Error("expected end of comment, got end of file")}return token(in_comment?TOKEN_COMMENT:TOKEN_DATA,tok,lineno,colno)}}throw new Error("Could not parse text")};Tokenizer.prototype.parseString=function(delimiter){this.forward();var lineno=this.lineno;var colno=this.colno;var str="";while(!this.is_finished()&&this.current()!=delimiter){var cur=this.current();if(cur=="\\"){this.forward();switch(this.current()){case"n":str+="\n";break;case"t":str+=" ";break;case"r":str+="\r";break;default:str+=this.current()}this.forward()}else{str+=cur;this.forward()}}this.forward();return str};Tokenizer.prototype._matches=function(str){if(this.index+str.length>this.length){return null}var m=this.str.slice(this.index,this.index+str.length);return m==str};Tokenizer.prototype._extractString=function(str){if(this._matches(str)){this.index+=str.length;return str}return null};Tokenizer.prototype._extractUntil=function(charString){return this._extractMatching(true,charString||"")};Tokenizer.prototype._extract=function(charString){return this._extractMatching(false,charString)};Tokenizer.prototype._extractMatching=function(breakOnMatch,charString){if(this.is_finished()){return null}var first=charString.indexOf(this.current());if(breakOnMatch&&first==-1||!breakOnMatch&&first!=-1){var t=this.current();this.forward();var idx=charString.indexOf(this.current());while((breakOnMatch&&idx==-1||!breakOnMatch&&idx!=-1)&&!this.is_finished()){t+=this.current();this.forward();idx=charString.indexOf(this.current())}return t}return""};Tokenizer.prototype.is_finished=function(){return this.index>=this.len};Tokenizer.prototype.forwardN=function(n){for(var i=0;i0&&!this.skip(lexer.TOKEN_COMMA)){this.fail("parseFrom: expected comma",fromTok.lineno,fromTok.colno)}var name=this.parsePrimary();if(name.value.charAt(0)=="_"){this.fail("parseFrom: names starting with an underscore "+"cannot be imported",name.lineno,name.colno)}if(this.skipSymbol("as")){var alias=this.parsePrimary();names.addChild(new nodes.Pair(name.lineno,name.colno,name,alias))}else{names.addChild(name)}}return node},parseBlock:function(){var tag=this.peekToken();if(!this.skipSymbol("block")){this.fail("parseBlock: expected block",tag.lineno,tag.colno)}var node=new nodes.Block(tag.lineno,tag.colno);node.name=this.parsePrimary();if(!(node.name instanceof nodes.Symbol)){this.fail("parseBlock: variable name expected",tag.lineno,tag.colno)}this.advanceAfterBlockEnd(tag.value);node.body=this.parseUntilBlocks("endblock");if(!this.peekToken()){this.fail("parseBlock: expected endblock, got end of file")}this.advanceAfterBlockEnd();return node},parseTemplateRef:function(tagName,nodeType){var tag=this.peekToken();if(!this.skipSymbol(tagName)){this.fail("parseTemplateRef: expected "+tagName)}var node=new nodeType(tag.lineno,tag.colno);node.template=this.parsePrimary();this.advanceAfterBlockEnd(tag.value);return node},parseExtends:function(){return this.parseTemplateRef("extends",nodes.Extends)},parseInclude:function(){return this.parseTemplateRef("include",nodes.Include)},parseIf:function(){var tag=this.peekToken();var node;if(this.skipSymbol("if")||this.skipSymbol("elif")){node=new nodes.If(tag.lineno,tag.colno)}else if(this.skipSymbol("ifAsync")){node=new nodes.IfAsync(tag.lineno,tag.colno)}else{this.fail("parseIf: expected if or elif",tag.lineno,tag.colno)}node.cond=this.parseExpression();this.advanceAfterBlockEnd(tag.value);node.body=this.parseUntilBlocks("elif","else","endif");var tok=this.peekToken();switch(tok&&tok.value){case"elif":node.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd();node.else_=this.parseUntilBlocks("endif");this.advanceAfterBlockEnd();break;case"endif":node.else_=null;this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected endif, else, or endif, "+"got end of file")}return node},parseSet:function(){var tag=this.peekToken();if(!this.skipSymbol("set")){this.fail("parseSet: expected set",tag.lineno,tag.colno)}var node=new nodes.Set(tag.lineno,tag.colno,[]);var target;while(target=this.parsePrimary()){node.targets.push(target);if(!this.skip(lexer.TOKEN_COMMA)){break}}if(!this.skipValue(lexer.TOKEN_OPERATOR,"=")){this.fail("parseSet: expected = in set tag",tag.lineno,tag.colno)}node.value=this.parseExpression();this.advanceAfterBlockEnd(tag.value);return node},parseStatement:function(){var tok=this.peekToken();var node;if(tok.type!=lexer.TOKEN_SYMBOL){this.fail("tag name expected",tok.lineno,tok.colno)}if(this.breakOnBlocks&&this.breakOnBlocks.indexOf(tok.value)!==-1){return null}switch(tok.value){case"raw":return this.parseRaw();case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"import":return this.parseImport();case"from":return this.parseFrom();default:if(this.extensions.length){for(var i=0;i1){this.fail("invalid index")}node=new nodes.LookupVal(tok.lineno,tok.colno,node,lookup.children[0])}else if(tok.type==lexer.TOKEN_OPERATOR&&tok.value=="."){this.nextToken();var val=this.nextToken();if(val.type!=lexer.TOKEN_SYMBOL){this.fail("expected name as lookup value, got "+val.value,val.lineno,val.colno)}var lookup=new nodes.Literal(val.lineno,val.colno,val.value);node=new nodes.LookupVal(tok.lineno,tok.colno,node,lookup)}else{break}tok=this.peekToken()}return node},parseExpression:function(){var node=this.parseInlineIf();return node},parseInlineIf:function(){var node=this.parseOr();if(this.skipSymbol("if")){var cond_node=this.parseOr();var body_node=node;node=new nodes.InlineIf(node.lineno,node.colno);node.body=body_node;node.cond=cond_node;if(this.skipSymbol("else")){node.else_=this.parseOr() }else{node.else_=null}}return node},parseOr:function(){var node=this.parseAnd();while(this.skipSymbol("or")){var node2=this.parseAnd();node=new nodes.Or(node.lineno,node.colno,node,node2)}return node},parseAnd:function(){var node=this.parseNot();while(this.skipSymbol("and")){var node2=this.parseNot();node=new nodes.And(node.lineno,node.colno,node,node2)}return node},parseNot:function(){var tok=this.peekToken();if(this.skipSymbol("not")){return new nodes.Not(tok.lineno,tok.colno,this.parseNot())}return this.parseCompare()},parseCompare:function(){var compareOps=["==","!=","<",">","<=",">="];var expr=this.parseAdd();var ops=[];while(1){var tok=this.nextToken();if(!tok){break}else if(compareOps.indexOf(tok.value)!==-1){ops.push(new nodes.CompareOperand(tok.lineno,tok.colno,this.parseAdd(),tok.value))}else if(tok.type==lexer.TOKEN_SYMBOL&&tok.value=="in"){ops.push(new nodes.CompareOperand(tok.lineno,tok.colno,this.parseAdd(),"in"))}else if(tok.type==lexer.TOKEN_SYMBOL&&tok.value=="not"&&this.skipSymbol("in")){ops.push(new nodes.CompareOperand(tok.lineno,tok.colno,this.parseAdd(),"notin"))}else{this.pushToken(tok);break}}if(ops.length){return new nodes.Compare(ops[0].lineno,ops[0].colno,expr,ops)}else{return expr}},parseAdd:function(){var node=this.parseSub();while(this.skipValue(lexer.TOKEN_OPERATOR,"+")){var node2=this.parseSub();node=new nodes.Add(node.lineno,node.colno,node,node2)}return node},parseSub:function(){var node=this.parseMul();while(this.skipValue(lexer.TOKEN_OPERATOR,"-")){var node2=this.parseMul();node=new nodes.Sub(node.lineno,node.colno,node,node2)}return node},parseMul:function(){var node=this.parseDiv();while(this.skipValue(lexer.TOKEN_OPERATOR,"*")){var node2=this.parseDiv();node=new nodes.Mul(node.lineno,node.colno,node,node2)}return node},parseDiv:function(){var node=this.parseFloorDiv();while(this.skipValue(lexer.TOKEN_OPERATOR,"/")){var node2=this.parseFloorDiv();node=new nodes.Div(node.lineno,node.colno,node,node2)}return node},parseFloorDiv:function(){var node=this.parseMod();while(this.skipValue(lexer.TOKEN_OPERATOR,"//")){var node2=this.parseMod();node=new nodes.FloorDiv(node.lineno,node.colno,node,node2)}return node},parseMod:function(){var node=this.parsePow();while(this.skipValue(lexer.TOKEN_OPERATOR,"%")){var node2=this.parsePow();node=new nodes.Mod(node.lineno,node.colno,node,node2)}return node},parsePow:function(){var node=this.parseUnary();while(this.skipValue(lexer.TOKEN_OPERATOR,"**")){var node2=this.parseUnary();node=new nodes.Pow(node.lineno,node.colno,node,node2)}return node},parseUnary:function(noFilters){var tok=this.peekToken();var node;if(this.skipValue(lexer.TOKEN_OPERATOR,"-")){node=new nodes.Neg(tok.lineno,tok.colno,this.parseUnary(true))}else if(this.skipValue(lexer.TOKEN_OPERATOR,"+")){node=new nodes.Pos(tok.lineno,tok.colno,this.parseUnary(true))}else{node=this.parsePrimary()}if(!noFilters){node=this.parseFilter(node)}return node},parsePrimary:function(noPostfix){var tok=this.nextToken();var val=null;var node=null;if(!tok){this.fail("expected expression, got end of file")}else if(tok.type==lexer.TOKEN_STRING){val=tok.value}else if(tok.type==lexer.TOKEN_INT){val=parseInt(tok.value,10)}else if(tok.type==lexer.TOKEN_FLOAT){val=parseFloat(tok.value)}else if(tok.type==lexer.TOKEN_BOOLEAN){if(tok.value=="true"){val=true}else if(tok.value=="false"){val=false}else{this.fail("invalid boolean: "+tok.val,tok.lineno,tok.colno)}}if(val!==null){node=new nodes.Literal(tok.lineno,tok.colno,val)}else if(tok.type==lexer.TOKEN_SYMBOL){node=new nodes.Symbol(tok.lineno,tok.colno,tok.value);if(!noPostfix){node=this.parsePostfix(node)}}else{this.pushToken(tok);node=this.parseAggregate()}if(node){return node}else{this.fail("unexpected token: "+tok.value,tok.lineno,tok.colno)}},parseFilter:function(node){while(this.skip(lexer.TOKEN_PIPE)){var tok=this.expect(lexer.TOKEN_SYMBOL);var name=tok.value;while(this.skipValue(lexer.TOKEN_OPERATOR,".")){name+="."+this.expect(lexer.TOKEN_SYMBOL).value}node=new nodes.Filter(tok.lineno,tok.colno,new nodes.Symbol(tok.lineno,tok.colno,name),new nodes.NodeList(tok.lineno,tok.colno,[node]));if(this.peekToken().type==lexer.TOKEN_LEFT_PAREN){var call=this.parsePostfix(node);node.args.children=node.args.children.concat(call.args.children)}}return node},parseAggregate:function(){var tok=this.nextToken();var node;switch(tok.type){case lexer.TOKEN_LEFT_PAREN:node=new nodes.Group(tok.lineno,tok.colno);break;case lexer.TOKEN_LEFT_BRACKET:node=new nodes.Array(tok.lineno,tok.colno);break;case lexer.TOKEN_LEFT_CURLY:node=new nodes.Dict(tok.lineno,tok.colno);break;default:return null}while(1){var type=this.peekToken().type;if(type==lexer.TOKEN_RIGHT_PAREN||type==lexer.TOKEN_RIGHT_BRACKET||type==lexer.TOKEN_RIGHT_CURLY){this.nextToken();break}if(node.children.length>0){if(!this.skip(lexer.TOKEN_COMMA)){this.fail("parseAggregate: expected comma after expression",tok.lineno,tok.colno)}}if(node instanceof nodes.Dict){var key=this.parsePrimary();if(!this.skip(lexer.TOKEN_COLON)){this.fail("parseAggregate: expected colon after dict key",tok.lineno,tok.colno)}var value=this.parseExpression();node.addChild(new nodes.Pair(key.lineno,key.colno,key,value))}else{var expr=this.parseExpression();node.addChild(expr)}}return node},parseSignature:function(tolerant,noParens){var tok=this.peekToken();if(!noParens&&tok.type!=lexer.TOKEN_LEFT_PAREN){if(tolerant){return null}else{this.fail("expected arguments",tok.lineno,tok.colno)}}if(tok.type==lexer.TOKEN_LEFT_PAREN){tok=this.nextToken()}var args=new nodes.NodeList(tok.lineno,tok.colno);var kwargs=new nodes.KeywordArgs(tok.lineno,tok.colno);var kwnames=[];var checkComma=false;while(1){tok=this.peekToken();if(!noParens&&tok.type==lexer.TOKEN_RIGHT_PAREN){this.nextToken();break}else if(noParens&&tok.type==lexer.TOKEN_BLOCK_END){break}if(checkComma&&!this.skip(lexer.TOKEN_COMMA)){this.fail("parseSignature: expected comma after expression",tok.lineno,tok.colno)}else{var arg=this.parseExpression();if(this.skipValue(lexer.TOKEN_OPERATOR,"=")){kwargs.addChild(new nodes.Pair(arg.lineno,arg.colno,arg,this.parseExpression()))}else{args.addChild(arg)}}checkComma=true}if(kwargs.children.length){args.addChild(kwargs)}return args},parseUntilBlocks:function(){var prev=this.breakOnBlocks;this.breakOnBlocks=lib.toArray(arguments);var ret=this.parse();this.breakOnBlocks=prev;return ret},parseNodes:function(){var tok;var buf=[];while(tok=this.nextToken()){if(tok.type==lexer.TOKEN_DATA){var data=tok.value;var nextToken=this.peekToken();var nextVal=nextToken&&nextToken.value;if(this.dropLeadingWhitespace){data=data.replace(/^\s*/,"");this.dropLeadingWhitespace=false}if(nextToken&&nextToken.type==lexer.TOKEN_BLOCK_START&&nextVal.charAt(nextVal.length-1)=="-"){data=data.replace(/\s*$/,"")}buf.push(new nodes.Output(tok.lineno,tok.colno,[new nodes.TemplateData(tok.lineno,tok.colno,data)]))}else if(tok.type==lexer.TOKEN_BLOCK_START){var n=this.parseStatement();if(!n){break}buf.push(n)}else if(tok.type==lexer.TOKEN_VARIABLE_START){var e=this.parseExpression();this.advanceAfterVariableEnd();buf.push(new nodes.Output(tok.lineno,tok.colno,[e]))}else if(tok.type!=lexer.TOKEN_COMMENT){this.fail("Unexpected token at top-level: "+tok.type,tok.lineno,tok.colno)}}return buf},parse:function(){return new nodes.NodeList(0,0,this.parseNodes())},parseAsRoot:function(){return new nodes.Root(0,0,this.parseNodes())}});modules["parser"]={parse:function(src,extensions){var p=new Parser(lexer.lex(src));if(extensions!==undefined){p.extensions=extensions}return p.parseAsRoot()}}})();(function(){var nodes=modules["nodes"];var sym=0;function gensym(){return"hole_"+sym++}function mapCOW(arr,func){var res=null;for(var i=0;i":">","<=":"<=",">=":">="};function binOpEmitter(str){return function(node,frame){this.compile(node.left,frame);this.emit(str);this.compile(node.right,frame)}}function quotedArray(arr){return"["+lib.map(arr,function(x){return'"'+x+'"'})+"]"}var Compiler=Object.extend({init:function(){this.codebuf=[];this.lastId=0;this.buffer=null;this.bufferStack=[];this.isChild=false;this.scopeClosers=""},fail:function(msg,lineno,colno){if(lineno!==undefined)lineno+=1;if(colno!==undefined)colno+=1;throw new lib.TemplateError(msg,lineno,colno)},pushBufferId:function(id){this.bufferStack.push(this.buffer);this.buffer=id;this.emit("var "+this.buffer+' = "";')},popBufferId:function(){this.buffer=this.bufferStack.pop()},emit:function(code){this.codebuf.push(code)},emitLine:function(code){this.emit(code+"\n")},emitLines:function(){lib.each(lib.toArray(arguments),function(line){this.emitLine(line)},this)},emitFuncBegin:function(name){this.buffer="output";this.scopeClosers="";this.emitLine("function "+name+"(env, context, frame, runtime, cb) {");this.emitLine("var lineno = null;");this.emitLine("var colno = null;");this.emitLine("var "+this.buffer+' = "";');this.emitLine("try {")},emitFuncEnd:function(noReturn){if(!noReturn){this.emitLine("cb(null, "+this.buffer+");")}this.closeScopeLevels();this.emitLine("} catch (e) {");this.emitLine(" cb(runtime.handleError(e, lineno, colno));");this.emitLine("}");this.emitLine("}");this.buffer=null},addScopeLevel:function(){this.scopeClosers+="})"},closeScopeLevels:function(){this.emitLine(this.scopeClosers+";");this.scopeClosers=""},withScopedSyntax:function(func){var scopeClosers=this.scopeClosers;this.scopeClosers="";func.call(this);this.closeScopeLevels();this.scopeClosers=scopeClosers},makeCallback:function(res){var err=this.tmpid();return"function("+err+(res?","+res:"")+") {\n"+"if("+err+") { cb("+err+"); return; }"},tmpid:function(){this.lastId++;return"t_"+this.lastId},_bufferAppend:function(func){this.emit(this.buffer+" += runtime.suppressValue(");func.call(this);this.emit(", env.autoesc);\n")},_compileChildren:function(node,frame){var children=node.children;for(var i=0,l=children.length;i0){this.emit(",")}this.compile(node.children[i],frame)}if(endChar){this.emit(endChar)}},_compileExpression:function(node,frame){this.assertType(node,nodes.Literal,nodes.Symbol,nodes.Group,nodes.Array,nodes.Dict,nodes.FunCall,nodes.Filter,nodes.LookupVal,nodes.Compare,nodes.InlineIf,nodes.And,nodes.Or,nodes.Not,nodes.Add,nodes.Sub,nodes.Mul,nodes.Div,nodes.FloorDiv,nodes.Mod,nodes.Pow,nodes.Neg,nodes.Pos,nodes.Compare,nodes.NodeList);this.compile(node,frame)},assertType:function(node){var types=lib.toArray(arguments).slice(1);var success=false;for(var i=0;i0){this.emit(",")}if(arg){var id=this.tmpid();this.emitLine("function(cb) {");this.emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");this.pushBufferId(id);this.withScopedSyntax(function(){this.compile(arg,frame);this.emitLine("cb(null, "+id+");")});this.popBufferId();this.emitLine("return "+id+";");this.emitLine("}")}else{this.emit("null")}},this)}if(async){var res=this.tmpid();this.emitLine(", "+this.makeCallback(res));this.emitLine(this.buffer+" += runtime.suppressValue("+res+", "+autoescape+" && env.autoesc);");this.addScopeLevel()}else{this.emit(")");this.emit(", "+autoescape+" && env.autoesc);\n")}},compileCallExtensionAsync:function(node,frame){this.compileCallExtension(node,frame,true)},compileNodeList:function(node,frame){this._compileChildren(node,frame)},compileLiteral:function(node,frame){if(typeof node.value=="string"){var val=node.value.replace(/\\/g,"\\\\");val=val.replace(/"/g,'\\"');val=val.replace(/\n/g,"\\n");val=val.replace(/\r/g,"\\r");val=val.replace(/\t/g,"\\t");this.emit('"'+val+'"')}else{this.emit(node.value.toString())}},compileSymbol:function(node,frame){var name=node.value;var v;if(v=frame.lookup(name)){this.emit(v)}else{this.emit("runtime.contextOrFrameLookup("+'context, frame, "'+name+'")')}},compileGroup:function(node,frame){this._compileAggregate(node,frame,"(",")")},compileArray:function(node,frame){this._compileAggregate(node,frame,"[","]")},compileDict:function(node,frame){this._compileAggregate(node,frame,"{","}")},compilePair:function(node,frame){var key=node.key;var val=node.value;if(key instanceof nodes.Symbol){key=new nodes.Literal(key.lineno,key.colno,key.value)}else if(!(key instanceof nodes.Literal&&typeof key.value=="string")){this.fail("compilePair: Dict keys must be strings or names",key.lineno,key.colno)}this.compile(key,frame);this.emit(": ");this._compileExpression(val,frame)},compileInlineIf:function(node,frame){this.emit("(");this.compile(node.cond,frame);this.emit("?");this.compile(node.body,frame);this.emit(":");if(node.else_!==null)this.compile(node.else_,frame);else this.emit('""');this.emit(")")},compileOr:binOpEmitter(" || "),compileAnd:binOpEmitter(" && "),compileAdd:binOpEmitter(" + "),compileSub:binOpEmitter(" - "),compileMul:binOpEmitter(" * "),compileDiv:binOpEmitter(" / "),compileMod:binOpEmitter(" % "),compileNot:function(node,frame){this.emit("!");this.compile(node.target,frame)},compileFloorDiv:function(node,frame){this.emit("Math.floor(");this.compile(node.left,frame);this.emit(" / ");this.compile(node.right,frame);this.emit(")")},compilePow:function(node,frame){this.emit("Math.pow(");this.compile(node.left,frame);this.emit(", ");this.compile(node.right,frame);this.emit(")")},compileNeg:function(node,frame){this.emit("-");this.compile(node.target,frame)},compilePos:function(node,frame){this.emit("+");this.compile(node.target,frame)},compileCompare:function(node,frame){this.compile(node.expr,frame);for(var i=0;i=width){return str}var spaces=width-str.length;var pre=lib.repeat(" ",spaces/2-spaces%2);var post=lib.repeat(" ",spaces/2);return r.copySafeness(str,pre+str+post)},"default":function(val,def){return val?val:def},dictsort:function(val,case_sensitive,by){if(!lib.isObject(val)){throw new lib.TemplateError("dictsort filter: val must be an object")}var array=[];for(var k in val){array.push([k,val[k]])}var si;if(by===undefined||by==="key"){si=0}else if(by==="value"){si=1}else{throw new lib.TemplateError("dictsort filter: You can only sort by either key or value")}array.sort(function(t1,t2){var a=t1[si];var b=t2[si];if(!case_sensitive){if(lib.isString(a)){a=a.toUpperCase()}if(lib.isString(b)){b=b.toUpperCase()}}return a>b?1:a==b?0:-1});return array},escape:function(str){if(typeof str=="string"||str instanceof r.SafeString){return lib.escape(str)}return str},safe:function(str){return r.markSafe(str)},first:function(arr){return arr[0]},groupby:function(arr,attr){return lib.groupBy(arr,attr)},indent:function(str,width,indentfirst){width=width||4;var res="";var lines=str.split("\n");var sp=lib.repeat(" ",width);for(var i=0;i=maxCount){break}last=res;res=res.replace(old,new_);count++}return r.copySafeness(str,res)},reverse:function(val){var arr;if(lib.isString(val)){arr=filters.list(val)}else{arr=lib.map(val,function(v){return v})}arr.reverse();if(lib.isString(val)){return r.copySafeness(val,arr.join(""))}return arr},round:function(val,precision,method){precision=precision||0;var factor=Math.pow(10,precision);var rounder;if(method=="ceil"){rounder=Math.ceil}else if(method=="floor"){rounder=Math.floor}else{rounder=Math.round}return rounder(val*factor)/factor},slice:function(arr,slices,fillWith){var sliceLength=Math.floor(arr.length/slices);var extra=arr.length%slices;var offset=0;var res=[];for(var i=0;i=extra){slice.push(fillWith)}res.push(slice)}return res},sort:function(arr,reverse,caseSens,attr){arr=lib.map(arr,function(v){return v});arr.sort(function(a,b){var x,y;if(attr){x=a[attr];y=b[attr]}else{x=a;y=b}if(!caseSens&&lib.isString(x)&&lib.isString(y)){x=x.toLowerCase();y=y.toLowerCase()}if(xy){return reverse?-1:1}else{return 0}});return arr},string:function(obj){return r.copySafeness(obj,obj)},title:function(str){var words=str.split(" ");for(var i=0;i"+possibleUrl.substr(0,length)+"";if(wwwRE.test(possibleUrl))return'"+possibleUrl.substr(0,length)+"";if(emailRE.test(possibleUrl))return''+possibleUrl+"";if(tldRE.test(possibleUrl))return'"+possibleUrl.substr(0,length)+"";return possibleUrl});return words.join(" ")},wordcount:function(str){var words=str?str.match(/\w+/g):null;return words?words.length:null},"float":function(val,def){var res=parseFloat(val);return isNaN(res)?def:res},"int":function(val,def){var res=parseInt(val,10);return isNaN(res)?def:res}};filters.d=filters["default"];filters.e=filters.escape;modules["filters"]=filters})();(function(){function cycler(items){var index=-1;var current=null;return{reset:function(){index=-1;current=null},next:function(){index++;if(index>=items.length){index=0}current=items[index];return current}}}function joiner(sep){sep=sep||",";var first=true;return function(){var val=first?"":sep;first=false;return val}}var globals={range:function(start,stop,step){if(!stop){stop=start;start=0;step=1}else if(!step){step=1}var arr=[];for(var i=start;i=width){return str}var spaces=width-str.length;var pre=lib.repeat(" ",spaces/2-spaces%2);var post=lib.repeat(" ",spaces/2);return r.copySafeness(str,pre+str+post)},"default":function(val,def){return val?val:def},dictsort:function(val,case_sensitive,by){if(!lib.isObject(val)){throw new lib.TemplateError("dictsort filter: val must be an object")}var array=[];for(var k in val){array.push([k,val[k]])}var si;if(by===undefined||by==="key"){si=0}else if(by==="value"){si=1}else{throw new lib.TemplateError("dictsort filter: You can only sort by either key or value")}array.sort(function(t1,t2){var a=t1[si];var b=t2[si];if(!case_sensitive){if(lib.isString(a)){a=a.toUpperCase()}if(lib.isString(b)){b=b.toUpperCase()}}return a>b?1:a==b?0:-1});return array},escape:function(str){if(typeof str=="string"||str instanceof r.SafeString){return lib.escape(str)}return str},safe:function(str){return r.markSafe(str)},first:function(arr){return arr[0]},groupby:function(arr,attr){return lib.groupBy(arr,attr)},indent:function(str,width,indentfirst){width=width||4;var res="";var lines=str.split("\n");var sp=lib.repeat(" ",width);for(var i=0;i=maxCount){break}last=res;res=res.replace(old,new_);count++}return r.copySafeness(str,res)},reverse:function(val){var arr;if(lib.isString(val)){arr=filters.list(val)}else{arr=lib.map(val,function(v){return v})}arr.reverse();if(lib.isString(val)){return r.copySafeness(val,arr.join(""))}return arr},round:function(val,precision,method){precision=precision||0;var factor=Math.pow(10,precision);var rounder;if(method=="ceil"){rounder=Math.ceil}else if(method=="floor"){rounder=Math.floor}else{rounder=Math.round}return rounder(val*factor)/factor},slice:function(arr,slices,fillWith){var sliceLength=Math.floor(arr.length/slices);var extra=arr.length%slices;var offset=0;var res=[];for(var i=0;i=extra){slice.push(fillWith)}res.push(slice)}return res},sort:function(arr,reverse,caseSens,attr){arr=lib.map(arr,function(v){return v});arr.sort(function(a,b){var x,y;if(attr){x=a[attr];y=b[attr]}else{x=a;y=b}if(!caseSens&&lib.isString(x)&&lib.isString(y)){x=x.toLowerCase();y=y.toLowerCase()}if(xy){return reverse?-1:1}else{return 0}});return arr},string:function(obj){return r.copySafeness(obj,obj)},title:function(str){var words=str.split(" ");for(var i=0;i"+possibleUrl.substr(0,length)+"";if(wwwRE.test(possibleUrl))return'"+possibleUrl.substr(0,length)+"";if(emailRE.test(possibleUrl))return''+possibleUrl+"";if(tldRE.test(possibleUrl))return'"+possibleUrl.substr(0,length)+"";return possibleUrl});return words.join(" ")},wordcount:function(str){var words=str?str.match(/\w+/g):null;return words?words.length:null},"float":function(val,def){var res=parseFloat(val);return isNaN(res)?def:res},"int":function(val,def){var res=parseInt(val,10);return isNaN(res)?def:res}};filters.d=filters["default"];filters.e=filters.escape;modules["filters"]=filters})();(function(){function cycler(items){var index=-1;var current=null;return{reset:function(){index=-1;current=null},next:function(){index++;if(index>=items.length){index=0}current=items[index];return current}}}function joiner(sep){sep=sep||",";var first=true;return function(){var val=first?"":sep;first=false;return val}}var globals={range:function(start,stop,step){if(!stop){stop=start;start=0;step=1}else if(!step){step=1}var arr=[];for(var i=start;i", "dependencies": { "optimist": "*",