From 88244a7b09609c26ec6fe059d0fb5fe1c227840c Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Fri, 25 Jan 2013 13:37:28 +0000 Subject: [PATCH] Update Handlebars.js to v1.0.rc.2 --- src/messenger/webim/js/libs/handlebars.js | 142 +++++++++++----------- 1 file changed, 72 insertions(+), 70 deletions(-) diff --git a/src/messenger/webim/js/libs/handlebars.js b/src/messenger/webim/js/libs/handlebars.js index 53a9cc73..1e86a63b 100644 --- a/src/messenger/webim/js/libs/handlebars.js +++ b/src/messenger/webim/js/libs/handlebars.js @@ -1,71 +1,73 @@ this.Handlebars={}; -(function(f){f.VERSION="1.0.rc.1";f.helpers={};f.partials={};f.registerHelper=function(h,c,d){if(d)c.not=d;this.helpers[h]=c};f.registerPartial=function(h,c){this.partials[h]=c};f.registerHelper("helperMissing",function(h){if(arguments.length!==2)throw Error("Could not find property '"+h+"'");});var j=Object.prototype.toString;f.registerHelper("blockHelperMissing",function(h,c){var d=c.inverse||function(){},g=c.fn,i=j.call(h);if(i==="[object Function]")h=h.call(this);return h===true?g(this):h===false|| -h==null?d(this):i==="[object Array]"?h.length>0?f.helpers.each(h,c):d(this):g(h)});f.K=function(){};f.createFrame=Object.create||function(h){f.K.prototype=h;h=new f.K;f.K.prototype=null;return h};f.registerHelper("each",function(h,c){var d=c.fn,g=c.inverse,i="",a;if(c.data)a=f.createFrame(c.data);if(h&&h.length>0){g=0;for(var b=h.length;g2&& -p.push("'"+this.terminals_[v]+"'");x=this.lexer.showPosition?"Parse error on line "+(l+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+p.join(", ")+", got '"+(this.terminals_[n]||n)+"'":"Parse error on line "+(l+1)+": Unexpected "+(n==1?"end of input":"'"+(this.terminals_[n]||n)+"'");this.parseError(x,{text:this.lexer.match,token:this.terminals_[n]||n,line:this.lexer.yylineno,loc:c,expected:p})}}if(o[0]instanceof Array&&o.length>1)throw Error("Parse Error: multiple actions possible at state: "+ -q+", token: "+n);switch(o[0]){case 1:i.push(n);a.push(this.lexer.yytext);b.push(this.lexer.yylloc);i.push(o[1]);n=null;if(w){n=w;w=null}else{m=this.lexer.yyleng;k=this.lexer.yytext;l=this.lexer.yylineno;c=this.lexer.yylloc;s>0&&s--}break;case 2:p=this.productions_[o[1]][1];u.$=a[a.length-p];u._$={first_line:b[b.length-(p||1)].first_line,last_line:b[b.length-1].last_line,first_column:b[b.length-(p||1)].first_column,last_column:b[b.length-1].last_column};if(r)u._$.range=[b[b.length-(p||1)].range[0], -b[b.length-1].range[1]];q=this.performAction.call(u,k,m,l,this.yy,o[1],a,b);if(typeof q!=="undefined")return q;if(p){i=i.slice(0,p*-2);a=a.slice(0,-1*p);b=b.slice(0,-1*p)}i.push(this.productions_[o[1]][0]);a.push(u.$);b.push(u._$);o=e[i[i.length-2]][i[i.length-1]];i.push(o);break;case 3:return true}}return true}},h=function(){var c={EOF:1,parseError:function(d,g){if(this.yy.parser)this.yy.parser.parseError(d,g);else throw Error(d);},setInput:function(d){this._input=d;this._more=this._less=this.done= -false;this.yylineno=this.yyleng=0;this.yytext=this.matched=this.match="";this.conditionStack=["INITIAL"];this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0};if(this.options.ranges)this.yylloc.range=[0,0];this.offset=0;return this},input:function(){var d=this._input[0];this.yytext+=d;this.yyleng++;this.offset++;this.match+=d;this.matched+=d;if(d.match(/(?:\r\n?|\n).*/g)){this.yylineno++;this.yylloc.last_line++}else this.yylloc.last_column++;this.options.ranges&&this.yylloc.range[1]++; -this._input=this._input.slice(1);return d},unput:function(d){var g=d.length,i=d.split(/(?:\r\n?|\n)/g);this._input=d+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-g-1);this.offset-=g;d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1);this.matched=this.matched.substr(0,this.matched.length-1);if(i.length-1)this.yylineno-=i.length-1;var a=this.yylloc.range;this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column, -last_column:i?(i.length===d.length?this.yylloc.first_column:0)+d[d.length-i.length].length-i[0].length:this.yylloc.first_column-g};if(this.options.ranges)this.yylloc.range=[a[0],a[0]+this.yyleng-g];return this},more:function(){this._more=true;return this},less:function(d){this.unput(this.match.slice(d))},pastInput:function(){var d=this.matched.substr(0,this.matched.length-this.match.length);return(d.length>20?"...":"")+d.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var d=this.match;if(d.length< -20)d+=this._input.substr(0,20-d.length);return(d.substr(0,20)+(d.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var d=this.pastInput(),g=Array(d.length+1).join("-");return d+this.upcomingInput()+"\n"+g+"^"},next:function(){if(this.done)return this.EOF;if(!this._input)this.done=true;var d,g,i;if(!this._more)this.match=this.yytext="";for(var a=this._currentRules(),b=0;bd[0].length)){d=g;i=b;if(!this.options.flex)break}if(d){if(g= -d[0].match(/(?:\r\n?|\n).*/g))this.yylineno+=g.length;this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:g?g[g.length-1].length-g[g.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+d[0].length};this.yytext+=d[0];this.match+=d[0];this.matches=d;this.yyleng=this.yytext.length;if(this.options.ranges)this.yylloc.range=[this.offset,this.offset+=this.yyleng];this._more=false;this._input=this._input.slice(d[0].length);this.matched+= -d[0];d=this.performAction.call(this,this.yy,this,a[i],this.conditionStack[this.conditionStack.length-1]);if(this.done&&this._input)this.done=false;if(d)return d;else return}return this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var d=this.next();return typeof d!=="undefined"?d:this.lex()},begin:function(d){this.conditionStack.push(d)},popState:function(){return this.conditionStack.pop()}, -_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(d){this.begin(d)}};c.options={};c.performAction=function(d,g,i){switch(i){case 0:g.yytext.slice(-1)!=="\\"&&this.begin("mu");if(g.yytext.slice(-1)==="\\"){g.yytext=g.yytext.substr(0,g.yyleng-1);this.begin("emu")}if(g.yytext)return 14;break;case 1:return 14;case 2:g.yytext.slice(-1)!=="\\"&&this.popState(); -if(g.yytext.slice(-1)==="\\")g.yytext=g.yytext.substr(0,g.yyleng-1);return 14;case 3:return 24;case 4:return 16;case 5:return 20;case 6:return 19;case 7:return 19;case 8:return 23;case 9:return 23;case 10:g.yytext=g.yytext.substr(3,g.yyleng-5);this.popState();return 15;case 11:return 22;case 12:return 35;case 13:return 34;case 14:return 34;case 15:return 37;case 17:this.popState();return 18;case 18:this.popState();return 18;case 19:g.yytext=g.yytext.substr(1,g.yyleng-2).replace(/\\"/g,'"');return 29; -case 20:g.yytext=g.yytext.substr(1,g.yyleng-2).replace(/\\"/g,'"');return 29;case 21:g.yytext=g.yytext.substr(1);return 27;case 22:return 31;case 23:return 31;case 24:return 30;case 25:return 34;case 26:g.yytext=g.yytext.substr(1,g.yyleng-2);return 34;case 27:return"INVALID";case 28:return 5}};c.rules=[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{![\s\S]*?\}\})/, -/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[} ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@[a-zA-Z]+)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:[0-9]+(?=[}\s]))/,/^(?:[a-zA-Z0-9_$-]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];c.conditions={mu:{rules:[3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28],inclusive:false},emu:{rules:[2],inclusive:false},INITIAL:{rules:[0,1,28],inclusive:true}};return c}(); -j.lexer=h;f.prototype=j;j.Parser=f;return new f}(); -if(typeof require!=="undefined"&&typeof exports!=="undefined"){exports.parser=handlebars;exports.Parser=handlebars.Parser;exports.parse=function(){return handlebars.parse.apply(handlebars,arguments)};exports.main=function(f){if(!f[1])throw Error("Usage: "+f[0]+" FILE");f=typeof process!=="undefined"?require("fs").readFileSync(require("path").resolve(f[1]),"utf8"):require("file").path(require("file").cwd()).join(f[1]).read({charset:"utf-8"});return exports.parser.parse(f)};if(typeof module!=="undefined"&& -require.main===module)exports.main(typeof process!=="undefined"?process.argv.slice(1):require("system").args)}Handlebars.Parser=handlebars;Handlebars.parse=function(f){Handlebars.Parser.yy=Handlebars.AST;return Handlebars.Parser.parse(f)};Handlebars.print=function(f){return(new Handlebars.PrintVisitor).accept(f)};Handlebars.logger={DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(){}};Handlebars.log=function(f,j){Handlebars.logger.log(f,j)}; -(function(){Handlebars.AST={};Handlebars.AST.ProgramNode=function(f,j){this.type="program";this.statements=f;if(j)this.inverse=new Handlebars.AST.ProgramNode(j)};Handlebars.AST.MustacheNode=function(f,j,h){this.type="mustache";this.escaped=!h;this.hash=j;h=this.id=f[0];f=this.params=f.slice(1);this.isHelper=(this.eligibleHelper=h.isSimple)&&(f.length||j)};Handlebars.AST.PartialNode=function(f,j){this.type="partial";this.id=f;this.context=j};Handlebars.AST.BlockNode=function(f,j,h,c){var d=f.id;if(d.original!== -c.original)throw new Handlebars.Exception(d.original+" doesn't match "+c.original);this.type="block";this.mustache=f;this.program=j;if((this.inverse=h)&&!this.program)this.isInverse=true};Handlebars.AST.ContentNode=function(f){this.type="content";this.string=f};Handlebars.AST.HashNode=function(f){this.type="hash";this.pairs=f};Handlebars.AST.IdNode=function(f){this.type="ID";this.original=f.join(".");for(var j=[],h=0,c=0,d=f.length;c":">",'"':""","'":"'","`":"`"},j=/[&<>"'`]/g,h=/[&<>"'`]/,c=function(d){return f[d]||"&"};Handlebars.Utils={escapeExpression:function(d){if(d instanceof Handlebars.SafeString)return d.toString();else if(d==null||d===false)return"";if(!h.test(d))return d;return d.replace(j,c)},isEmpty:function(d){return typeof d==="undefined"?true:d===null?true:d===false?true:Object.prototype.toString.call(d)==="[object Array]"&&d.length===0?true:false}}})(); -Handlebars.Compiler=function(){};Handlebars.JavaScriptCompiler=function(){}; -(function(f,j){f.prototype={compiler:f,disassemble:function(){for(var a=this.opcodes,b,e=[],k,l,m=0,s=a.length;mthis.stackVars.length&&this.stackVars.push("stack"+this.stackSlot);return"stack"+this.stackSlot},popStack:function(){var a=this.compileStack.pop();if(a instanceof h)return a.value;else{this.stackSlot--;return a}},topStack:function(){var a=this.compileStack[this.compileStack.length-1];return a instanceof h?a.value:a},quotedString:function(a){return'"'+ -a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r")+'"'},setupHelper:function(a,b){var e=[];this.setupParams(a,e);var k=this.nameLookup("helpers",b,"helper");return{params:e,name:k,callParams:["depth0"].concat(e).join(", "),helperMissingParams:["depth0",this.quotedString(b)].concat(e).join(", ")}},setupParams:function(a,b){var e=[],k=[],l,m;e.push("hash:"+this.popStack());l=this.popStack();if((m=this.popStack())||l){if(!m){this.context.aliases.self="this";m="self.noop"}if(!l){this.context.aliases.self= -"this";l="self.noop"}e.push("inverse:"+l);e.push("fn:"+m)}for(m=0;ma.length&&(a+=this._input.substr(0, +20-a.length));return(a.substr(0,20)+(20a[0].length))if(a=d,c=f,!this.options.flex)break;if(a){if(d=a[0].match(/(?:\r\n?|\n).*/g))this.yylineno+= +d.length;this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:d?d[d.length-1].length-d[d.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length};this.yytext+=a[0];this.match+=a[0];this.matches=a;this.yyleng=this.yytext.length;this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]);this._more=!1;this._input=this._input.slice(a[0].length);this.matched+=a[0];a=this.performAction.call(this,this.yy, +this,e[c],this.conditionStack[this.conditionStack.length-1]);this.done&&this._input&&(this.done=!1);if(a)return a}else return""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return"undefined"!==typeof a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length- +1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(a){this.begin(a)},options:{},performAction:function(a,d,c){switch(c){case 0:"\\"!==d.yytext.slice(-1)&&this.begin("mu");"\\"===d.yytext.slice(-1)&&(d.yytext=d.yytext.substr(0,d.yyleng-1),this.begin("emu"));if(d.yytext)return 14;break;case 1:return 14;case 2:return"\\"!==d.yytext.slice(-1)&&this.popState(),"\\"===d.yytext.slice(-1)&&(d.yytext=d.yytext.substr(0,d.yyleng-1)),14;case 3:return d.yytext= +d.yytext.substr(0,d.yyleng-4),this.popState(),15;case 4:return this.begin("par"),24;case 5:return 16;case 6:return 20;case 7:return 19;case 8:return 19;case 9:return 23;case 10:return 23;case 11:this.popState();this.begin("com");break;case 12:return d.yytext=d.yytext.substr(3,d.yyleng-5),this.popState(),15;case 13:return 22;case 14:return 36;case 15:return 35;case 16:return 35;case 17:return 39;case 19:return this.popState(),18;case 20:return this.popState(),18;case 21:return d.yytext=d.yytext.substr(1, +d.yyleng-2).replace(/\\"/g,'"'),30;case 22:return d.yytext=d.yytext.substr(1,d.yyleng-2).replace(/\\'/g,"'"),30;case 23:return d.yytext=d.yytext.substr(1),28;case 24:return 32;case 25:return 32;case 26:return 31;case 27:return 35;case 28:return d.yytext=d.yytext.substr(1,d.yyleng-2),35;case 29:return"INVALID";case 31:return this.popState(),37;case 32:return 5}},rules:[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/, +/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[} ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@[a-zA-Z]+)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:[0-9]+(?=[}\s]))/,/^(?:[a-zA-Z0-9_$-]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:\s+)/,/^(?:[a-zA-Z0-9_$-/]+)/,/^(?:$)/],conditions:{mu:{rules:[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18, +19,20,21,22,23,24,25,26,27,28,29,32],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[3],inclusive:!1},par:{rules:[30,31],inclusive:!1},INITIAL:{rules:[0,1,32],inclusive:!0}}}};c.prototype=f;f.Parser=c;return new c}();Handlebars.Parser=handlebars;Handlebars.parse=function(c){Handlebars.Parser.yy=Handlebars.AST;return Handlebars.Parser.parse(c)};Handlebars.print=function(c){return(new Handlebars.PrintVisitor).accept(c)}; +(function(){Handlebars.AST={};Handlebars.AST.ProgramNode=function(c,f){this.type="program";this.statements=c;f&&(this.inverse=new Handlebars.AST.ProgramNode(f))};Handlebars.AST.MustacheNode=function(c,f,a){this.type="mustache";this.escaped=!a;this.hash=f;a=this.id=c[0];c=this.params=c.slice(1);this.isHelper=(this.eligibleHelper=a.isSimple)&&(c.length||f)};Handlebars.AST.PartialNode=function(c,f){this.type="partial";this.partialName=c;this.context=f};Handlebars.AST.BlockNode=function(c,f,a,d){var g= +c.id;if(g.original!==d.original)throw new Handlebars.Exception(g.original+" doesn't match "+d.original);this.type="block";this.mustache=c;this.program=f;if((this.inverse=a)&&!this.program)this.isInverse=!0};Handlebars.AST.ContentNode=function(c){this.type="content";this.string=c};Handlebars.AST.HashNode=function(c){this.type="hash";this.pairs=c};Handlebars.AST.IdNode=function(c){this.type="ID";this.original=c.join(".");for(var f=[],a=0,d=0,g=c.length;d":">",'"':""","'":"'","`":"`"},f=/[&<>"'`]/g,a=/[&<>"'`]/,d=function(a){return c[a]||"&"};Handlebars.Utils={escapeExpression:function(c){return c instanceof Handlebars.SafeString?c.toString():null==c||!1===c?"":!a.test(c)?c:c.replace(f,d)},isEmpty:function(a){return!a&&0!==a?!0:"[object Array]"===Object.prototype.toString.call(a)&&0===a.length?!0:!1}}})();Handlebars.Compiler=function(){};Handlebars.JavaScriptCompiler=function(){}; +(function(c,f){c.prototype={compiler:c,disassemble:function(){for(var b=this.opcodes,a,c=[],d,e,f=0,g=b.length;fc||this.addDepth(c-1);return a},block:function(b){var a=b.mustache,c=b.program;b=b.inverse;c&&(c=this.compileProgram(c));b&&(b=this.compileProgram(b));var d=this.classifyMustache(a);"helper"===d?this.helperMustache(a,c,b):"simple"===d?(this.simpleMustache(a),this.opcode("pushProgram",c),this.opcode("pushProgram",b),this.opcode("pushHash"),this.opcode("blockValue")):(this.ambiguousMustache(a, +c,b),this.opcode("pushProgram",c),this.opcode("pushProgram",b),this.opcode("pushHash"),this.opcode("ambiguousBlockValue"));this.opcode("append")},hash:function(b){b=b.pairs;var a,c;this.opcode("pushHash");for(var d=0,e=b.length;dthis.stackVars.length&&this.stackVars.push("stack"+this.stackSlot);return"stack"+this.stackSlot},popStack:function(){var b=this.compileStack.pop(); +if(b instanceof a)return b.value;this.stackSlot--;return b},topStack:function(){var b=this.compileStack[this.compileStack.length-1];return b instanceof a?b.value:b},quotedString:function(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r")+'"'},setupHelper:function(a,c){var d=[];this.setupParams(a,d);var e=this.nameLookup("helpers",c,"helper");return{params:d,name:e,callParams:["depth0"].concat(d).join(", "),helperMissingParams:["depth0",this.quotedString(c)].concat(d).join(", ")}}, +setupParams:function(a,c){var d=[],e=[],f=[],g,l;d.push("hash:"+this.popStack());g=this.popStack();if((l=this.popStack())||g)l||(this.context.aliases.self="this",l="self.noop"),g||(this.context.aliases.self="this",g="self.noop"),d.push("inverse:"+g),d.push("fn:"+l);for(l=0;l