mirror of
https://github.com/Mibew/java.git
synced 2025-01-23 01:50:34 +03:00
Add Handlebars JavaScript template engine
This commit is contained in:
parent
56a50c9df4
commit
36c8e6c042
71
src/messenger/webim/js/164/handlebars.js
Normal file
71
src/messenger/webim/js/164/handlebars.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
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;g<b;g++){if(a)a.index=g;i+=d(h[g],{data:a})}}else i=g(this);return i});f.registerHelper("if",function(h,c){if(j.call(h)==="[object Function]")h=h.call(this);return!h||
|
||||||
|
f.Utils.isEmpty(h)?c.inverse(this):c.fn(this)});f.registerHelper("unless",function(h,c){var d=c.fn;c.fn=c.inverse;c.inverse=d;return f.helpers["if"].call(this,h,c)});f.registerHelper("with",function(h,c){return c.fn(h)});f.registerHelper("log",function(h){f.log(h)})})(this.Handlebars);
|
||||||
|
var handlebars=function(){function f(){this.yy={}}var j={trace:function(){},yy:{},symbols_:{error:2,root:3,program:4,EOF:5,statements:6,simpleInverse:7,statement:8,openInverse:9,closeBlock:10,openBlock:11,mustache:12,partial:13,CONTENT:14,COMMENT:15,OPEN_BLOCK:16,inMustache:17,CLOSE:18,OPEN_INVERSE:19,OPEN_ENDBLOCK:20,path:21,OPEN:22,OPEN_UNESCAPED:23,OPEN_PARTIAL:24,params:25,hash:26,DATA:27,param:28,STRING:29,INTEGER:30,BOOLEAN:31,hashSegments:32,hashSegment:33,ID:34,EQUALS:35,pathSegments:36,SEP:37,
|
||||||
|
$accept:0,$end:1},terminals_:{2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"OPEN_PARTIAL",27:"DATA",29:"STRING",30:"INTEGER",31:"BOOLEAN",34:"ID",35:"EQUALS",37:"SEP"},productions_:[0,[3,2],[4,3],[4,1],[4,0],[6,1],[6,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[7,2],[17,3],[17,2],[17,2],[17,1],[17,1],[25,2],[25,1],[28,1],[28,1],[28,1],[28,1],[28,1],[26,1],[32,
|
||||||
|
2],[32,1],[33,3],[33,3],[33,3],[33,3],[33,3],[21,1],[36,3],[36,1]],performAction:function(c,d,g,i,a,b){c=b.length-1;switch(a){case 1:return b[c-1];case 2:this.$=new i.ProgramNode(b[c-2],b[c]);break;case 3:this.$=new i.ProgramNode(b[c]);break;case 4:this.$=new i.ProgramNode([]);break;case 5:this.$=[b[c]];break;case 6:b[c-1].push(b[c]);this.$=b[c-1];break;case 7:this.$=new i.BlockNode(b[c-2],b[c-1].inverse,b[c-1],b[c]);break;case 8:this.$=new i.BlockNode(b[c-2],b[c-1],b[c-1].inverse,b[c]);break;case 9:this.$=
|
||||||
|
b[c];break;case 10:this.$=b[c];break;case 11:this.$=new i.ContentNode(b[c]);break;case 12:this.$=new i.CommentNode(b[c]);break;case 13:this.$=new i.MustacheNode(b[c-1][0],b[c-1][1]);break;case 14:this.$=new i.MustacheNode(b[c-1][0],b[c-1][1]);break;case 15:this.$=b[c-1];break;case 16:this.$=new i.MustacheNode(b[c-1][0],b[c-1][1]);break;case 17:this.$=new i.MustacheNode(b[c-1][0],b[c-1][1],true);break;case 18:this.$=new i.PartialNode(b[c-1]);break;case 19:this.$=new i.PartialNode(b[c-2],b[c-1]);break;
|
||||||
|
case 21:this.$=[[b[c-2]].concat(b[c-1]),b[c]];break;case 22:this.$=[[b[c-1]].concat(b[c]),null];break;case 23:this.$=[[b[c-1]],b[c]];break;case 24:this.$=[[b[c]],null];break;case 25:this.$=[[new i.DataNode(b[c])],null];break;case 26:b[c-1].push(b[c]);this.$=b[c-1];break;case 27:this.$=[b[c]];break;case 28:this.$=b[c];break;case 29:this.$=new i.StringNode(b[c]);break;case 30:this.$=new i.IntegerNode(b[c]);break;case 31:this.$=new i.BooleanNode(b[c]);break;case 32:this.$=new i.DataNode(b[c]);break;
|
||||||
|
case 33:this.$=new i.HashNode(b[c]);break;case 34:b[c-1].push(b[c]);this.$=b[c-1];break;case 35:this.$=[b[c]];break;case 36:this.$=[b[c-2],b[c]];break;case 37:this.$=[b[c-2],new i.StringNode(b[c])];break;case 38:this.$=[b[c-2],new i.IntegerNode(b[c])];break;case 39:this.$=[b[c-2],new i.BooleanNode(b[c])];break;case 40:this.$=[b[c-2],new i.DataNode(b[c])];break;case 41:this.$=new i.IdNode(b[c]);break;case 42:b[c-2].push(b[c]);this.$=b[c-2];break;case 43:this.$=[b[c]]}},table:[{3:1,4:2,5:[2,4],6:3,
|
||||||
|
8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{1:[3]},{5:[1,16]},{5:[2,3],7:17,8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,19],20:[2,3],22:[1,13],23:[1,14],24:[1,15]},{5:[2,5],14:[2,5],15:[2,5],16:[2,5],19:[2,5],20:[2,5],22:[2,5],23:[2,5],24:[2,5]},{4:20,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{4:21,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,
|
||||||
|
4],22:[1,13],23:[1,14],24:[1,15]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],24:[2,9]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],24:[2,10]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],24:[2,11]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],24:[2,12]},{17:22,21:23,27:[1,24],34:[1,26],36:25},{17:27,21:23,27:[1,24],34:[1,26],36:25},{17:28,21:23,27:[1,24],34:[1,26],
|
||||||
|
36:25},{17:29,21:23,27:[1,24],34:[1,26],36:25},{21:30,34:[1,26],36:25},{1:[2,1]},{6:31,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{5:[2,6],14:[2,6],15:[2,6],16:[2,6],19:[2,6],20:[2,6],22:[2,6],23:[2,6],24:[2,6]},{17:22,18:[1,32],21:23,27:[1,24],34:[1,26],36:25},{10:33,20:[1,34]},{10:35,20:[1,34]},{18:[1,36]},{18:[2,24],21:41,25:37,26:38,27:[1,45],28:39,29:[1,42],30:[1,43],31:[1,44],32:40,33:46,34:[1,47],36:25},{18:[2,25]},{18:[2,41],27:[2,41],29:[2,
|
||||||
|
41],30:[2,41],31:[2,41],34:[2,41],37:[1,48]},{18:[2,43],27:[2,43],29:[2,43],30:[2,43],31:[2,43],34:[2,43],37:[2,43]},{18:[1,49]},{18:[1,50]},{18:[1,51]},{18:[1,52],21:53,34:[1,26],36:25},{5:[2,2],8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,2],22:[1,13],23:[1,14],24:[1,15]},{14:[2,20],15:[2,20],16:[2,20],19:[2,20],22:[2,20],23:[2,20],24:[2,20]},{5:[2,7],14:[2,7],15:[2,7],16:[2,7],19:[2,7],20:[2,7],22:[2,7],23:[2,7],24:[2,7]},{21:54,34:[1,26],36:25},{5:[2,8],14:[2,8],15:[2,
|
||||||
|
8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],24:[2,8]},{14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],24:[2,14]},{18:[2,22],21:41,26:55,27:[1,45],28:56,29:[1,42],30:[1,43],31:[1,44],32:40,33:46,34:[1,47],36:25},{18:[2,23]},{18:[2,27],27:[2,27],29:[2,27],30:[2,27],31:[2,27],34:[2,27]},{18:[2,33],33:57,34:[1,58]},{18:[2,28],27:[2,28],29:[2,28],30:[2,28],31:[2,28],34:[2,28]},{18:[2,29],27:[2,29],29:[2,29],30:[2,29],31:[2,29],34:[2,29]},{18:[2,30],27:[2,30],29:[2,30],30:[2,
|
||||||
|
30],31:[2,30],34:[2,30]},{18:[2,31],27:[2,31],29:[2,31],30:[2,31],31:[2,31],34:[2,31]},{18:[2,32],27:[2,32],29:[2,32],30:[2,32],31:[2,32],34:[2,32]},{18:[2,35],34:[2,35]},{18:[2,43],27:[2,43],29:[2,43],30:[2,43],31:[2,43],34:[2,43],35:[1,59],37:[2,43]},{34:[1,60]},{14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],24:[2,13]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],24:[2,16]},{5:[2,17],14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,
|
||||||
|
17],23:[2,17],24:[2,17]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],24:[2,18]},{18:[1,61]},{18:[1,62]},{18:[2,21]},{18:[2,26],27:[2,26],29:[2,26],30:[2,26],31:[2,26],34:[2,26]},{18:[2,34],34:[2,34]},{35:[1,59]},{21:63,27:[1,67],29:[1,64],30:[1,65],31:[1,66],34:[1,26],36:25},{18:[2,42],27:[2,42],29:[2,42],30:[2,42],31:[2,42],34:[2,42],37:[2,42]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],24:[2,19]},{5:[2,15],14:[2,15],15:[2,
|
||||||
|
15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],24:[2,15]},{18:[2,36],34:[2,36]},{18:[2,37],34:[2,37]},{18:[2,38],34:[2,38]},{18:[2,39],34:[2,39]},{18:[2,40],34:[2,40]}],defaultActions:{16:[2,1],24:[2,25],38:[2,23],55:[2,21]},parseError:function(c){throw Error(c);},parse:function(c){function d(){var t;t=g.lexer.lex()||1;if(typeof t!=="number")t=g.symbols_[t]||t;return t}var g=this,i=[0],a=[null],b=[],e=this.table,k="",l=0,m=0,s=0;this.lexer.setInput(c);this.lexer.yy=this.yy;this.yy.lexer=this.lexer;
|
||||||
|
this.yy.parser=this;if(typeof this.lexer.yylloc=="undefined")this.lexer.yylloc={};c=this.lexer.yylloc;b.push(c);var r=this.lexer.options&&this.lexer.options.ranges;if(typeof this.yy.parseError==="function")this.parseError=this.yy.parseError;for(var n,w,q,o,u={},v,p;;){q=i[i.length-1];if(this.defaultActions[q])o=this.defaultActions[q];else{if(n===null||typeof n=="undefined")n=d();o=e[q]&&e[q][n]}if(typeof o==="undefined"||!o.length||!o[0]){var x="";if(!s){p=[];for(v in e[q])this.terminals_[v]&&v>2&&
|
||||||
|
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;b<a.length;b++)if((g=this._input.match(this.rules[a[b]]))&&(!d||g[0].length>d[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<d;c++){var g=f[c];if(g==="..")h++;else if(g==="."||g==="this")this.isScoped=
|
||||||
|
true;else j.push(g)}this.parts=j;this.string=j.join(".");this.depth=h;this.isSimple=f.length===1&&!this.isScoped&&h===0};Handlebars.AST.DataNode=function(f){this.type="DATA";this.id=f};Handlebars.AST.StringNode=function(f){this.type="STRING";this.string=f};Handlebars.AST.IntegerNode=function(f){this.type="INTEGER";this.integer=f};Handlebars.AST.BooleanNode=function(f){this.type="BOOLEAN";this.bool=f};Handlebars.AST.CommentNode=function(f){this.type="comment";this.comment=f}})();
|
||||||
|
Handlebars.Exception=function(){var f=Error.prototype.constructor.apply(this,arguments),j;for(j in f)if(f.hasOwnProperty(j))this[j]=f[j];this.message=f.message};Handlebars.Exception.prototype=Error();Handlebars.SafeString=function(f){this.string=f};Handlebars.SafeString.prototype.toString=function(){return this.string.toString()};
|
||||||
|
(function(){var f={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},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;m<s;m++){b=a[m];if(b.opcode==="DECLARE")e.push("DECLARE "+b.name+"="+b.value);else{k=[];for(var r=0;r<b.args.length;r++){l=b.args[r];if(typeof l==="string")l='"'+l.replace("\n","\\n")+'"';k.push(l)}e.push(b.opcode+" "+k.join(" "))}}return e.join("\n")},guid:0,compile:function(a,b){this.children=[];this.depths={list:[]};this.options=b;var e=this.options.knownHelpers;this.options.knownHelpers=
|
||||||
|
{helperMissing:true,blockHelperMissing:true,each:true,"if":true,unless:true,"with":true,log:true};if(e)for(var k in e)this.options.knownHelpers[k]=e[k];return this.program(a)},accept:function(a){return this[a.type](a)},program:function(a){a=a.statements;var b;this.opcodes=[];for(var e=0,k=a.length;e<k;e++){b=a[e];this[b.type](b)}this.isSimple=k===1;this.depths.list=this.depths.list.sort(function(l,m){return l-m});return this},compileProgram:function(a){a=(new this.compiler).compile(a,this.options);
|
||||||
|
var b=this.guid++,e;this.usePartial=this.usePartial||a.usePartial;this.children[b]=a;for(var k=0,l=a.depths.list.length;k<l;k++){e=a.depths.list[k];e<2||this.addDepth(e-1)}return b},block:function(a){var b=a.mustache,e=a.program;a=a.inverse;if(e)e=this.compileProgram(e);if(a)a=this.compileProgram(a);var k=this.classifyMustache(b);if(k==="helper")this.helperMustache(b,e,a);else if(k==="simple"){this.simpleMustache(b);this.opcode("pushProgram",e);this.opcode("pushProgram",a);this.opcode("pushLiteral",
|
||||||
|
"{}");this.opcode("blockValue")}else{this.ambiguousMustache(b,e,a);this.opcode("pushProgram",e);this.opcode("pushProgram",a);this.opcode("pushLiteral","{}");this.opcode("ambiguousBlockValue")}this.opcode("append")},hash:function(a){a=a.pairs;var b,e;this.opcode("push","{}");for(var k=0,l=a.length;k<l;k++){b=a[k];e=b[1];this.accept(e);this.opcode("assignToHash",b[0])}},partial:function(a){var b=a.id;this.usePartial=true;a.context?this.ID(a.context):this.opcode("push","depth0");this.opcode("invokePartial",
|
||||||
|
b.original);this.opcode("append")},content:function(a){this.opcode("appendContent",a.string)},mustache:function(a){var b=this.options,e=this.classifyMustache(a);if(e==="simple")this.simpleMustache(a);else e==="helper"?this.helperMustache(a):this.ambiguousMustache(a);a.escaped&&!b.noEscape?this.opcode("appendEscaped"):this.opcode("append")},ambiguousMustache:function(a,b,e){a=a.id;var k=a.parts[0];this.opcode("getContext",a.depth);this.opcode("pushProgram",b);this.opcode("pushProgram",e);this.opcode("invokeAmbiguous",
|
||||||
|
k)},simpleMustache:function(a){a=a.id;if(a.type==="DATA")this.DATA(a);else if(a.parts.length)this.ID(a);else{this.addDepth(a.depth);this.opcode("getContext",a.depth);this.opcode("pushContext")}this.opcode("resolvePossibleLambda")},helperMustache:function(a,b,e){b=this.setupFullMustacheParams(a,b,e);a=a.id.parts[0];if(this.options.knownHelpers[a])this.opcode("invokeKnownHelper",b.length,a);else if(this.knownHelpersOnly)throw Error("You specified knownHelpersOnly, but used the unknown helper "+a);else this.opcode("invokeHelper",
|
||||||
|
b.length,a)},ID:function(a){this.addDepth(a.depth);this.opcode("getContext",a.depth);a.parts[0]?this.opcode("lookupOnContext",a.parts[0]):this.opcode("pushContext");for(var b=1,e=a.parts.length;b<e;b++)this.opcode("lookup",a.parts[b])},DATA:function(a){this.options.data=true;this.opcode("lookupData",a.id)},STRING:function(a){this.opcode("pushString",a.string)},INTEGER:function(a){this.opcode("pushLiteral",a.integer)},BOOLEAN:function(a){this.opcode("pushLiteral",a.bool)},comment:function(){},opcode:function(a){this.opcodes.push({opcode:a,
|
||||||
|
args:[].slice.call(arguments,1)})},declare:function(a,b){this.opcodes.push({opcode:"DECLARE",name:a,value:b})},addDepth:function(a){if(isNaN(a))throw Error("EWOT");if(a!==0)if(!this.depths[a]){this.depths[a]=true;this.depths.list.push(a)}},classifyMustache:function(a){var b=a.isHelper,e=a.eligibleHelper,k=this.options;if(e&&!b)if(k.knownHelpers[a.id.parts[0]])b=true;else if(k.knownHelpersOnly)e=false;return b?"helper":e?"ambiguous":"simple"},pushParams:function(a){for(var b=a.length,e;b--;){e=a[b];
|
||||||
|
if(this.options.stringParams){e.depth&&this.addDepth(e.depth);this.opcode("getContext",e.depth||0);this.opcode("pushStringParam",e.string)}else this[e.type](e)}},setupMustacheParams:function(a){var b=a.params;this.pushParams(b);a.hash?this.hash(a.hash):this.opcode("pushLiteral","{}");return b},setupFullMustacheParams:function(a,b,e){var k=a.params;this.pushParams(k);this.opcode("pushProgram",b);this.opcode("pushProgram",e);a.hash?this.hash(a.hash):this.opcode("pushLiteral","{}");return k}};var h=
|
||||||
|
function(a){this.value=a};j.prototype={nameLookup:function(a,b){return/^[0-9]+$/.test(b)?a+"["+b+"]":j.isValidJavaScriptVariableName(b)?a+"."+b:a+"['"+b+"']"},appendToBuffer:function(a){return this.environment.isSimple?"return "+a+";":"buffer += "+a+";"},initializeBuffer:function(){return this.quotedString("")},namespace:"Handlebars",compile:function(a,b,e,k){this.environment=a;this.options=b||{};Handlebars.log(Handlebars.logger.DEBUG,this.environment.disassemble()+"\n\n");this.name=this.environment.name;
|
||||||
|
this.isChild=!!e;this.context=e||{programs:[],aliases:{}};this.preamble();this.stackSlot=0;this.stackVars=[];this.registers={list:[]};this.compileStack=[];this.compileChildren(a,b);a=a.opcodes;this.i=0;for(i=a.length;this.i<i;this.i++){b=a[this.i];if(b.opcode==="DECLARE")this[b.name]=b.value;else this[b.opcode].apply(this,b.args)}return this.createFunctionContext(k)},nextOpcode:function(){return this.environment.opcodes[this.i+1]},eat:function(){this.i+=1},preamble:function(){var a=[];if(this.isChild)a.push("");
|
||||||
|
else{var b=this.namespace,e="helpers = helpers || "+b+".helpers;";if(this.environment.usePartial)e=e+" partials = partials || "+b+".partials;";if(this.options.data)e+=" data = data || {};";a.push(e)}this.environment.isSimple?a.push(""):a.push(", buffer = "+this.initializeBuffer());this.lastContext=0;this.source=a},createFunctionContext:function(a){var b=this.stackVars.concat(this.registers.list);if(b.length>0)this.source[1]=this.source[1]+", "+b.join(", ");if(!this.isChild)for(var e in this.context.aliases)this.source[1]=
|
||||||
|
this.source[1]+", "+e+"="+this.context.aliases[e];if(this.source[1])this.source[1]="var "+this.source[1].substring(2)+";";this.isChild||(this.source[1]+="\n"+this.context.programs.join("\n")+"\n");this.environment.isSimple||this.source.push("return buffer;");b=this.isChild?["depth0","data"]:["Handlebars","depth0","helpers","partials","data"];e=0;for(var k=this.environment.depths.list.length;e<k;e++)b.push("depth"+this.environment.depths.list[e]);if(a){b.push(this.source.join("\n "));return Function.apply(this,
|
||||||
|
b)}else{a="function "+(this.name||"")+"("+b.join(",")+") {\n "+this.source.join("\n ")+"}";Handlebars.log(Handlebars.logger.DEBUG,a+"\n\n");return a}},blockValue:function(){this.context.aliases.blockHelperMissing="helpers.blockHelperMissing";var a=["depth0"];this.setupParams(0,a);this.replaceStack(function(b){a.splice(1,0,b);return b+" = blockHelperMissing.call("+a.join(", ")+")"})},ambiguousBlockValue:function(){this.context.aliases.blockHelperMissing="helpers.blockHelperMissing";var a=["depth0"];
|
||||||
|
this.setupParams(0,a);var b=this.topStack();a.splice(1,0,b);this.source.push("if (!"+this.lastHelper+") { "+b+" = blockHelperMissing.call("+a.join(", ")+"); }")},appendContent:function(a){this.source.push(this.appendToBuffer(this.quotedString(a)))},append:function(){var a=this.popStack();this.source.push("if("+a+" || "+a+" === 0) { "+this.appendToBuffer(a)+" }");this.environment.isSimple&&this.source.push("else { "+this.appendToBuffer("''")+" }")},appendEscaped:function(){var a=this.nextOpcode(),
|
||||||
|
b="";this.context.aliases.escapeExpression="this.escapeExpression";if(a&&a.opcode==="appendContent"){b=" + "+this.quotedString(a.args[0]);this.eat(a)}this.source.push(this.appendToBuffer("escapeExpression("+this.popStack()+")"+b))},getContext:function(a){if(this.lastContext!==a)this.lastContext=a},lookupOnContext:function(a){this.pushStack(this.nameLookup("depth"+this.lastContext,a,"context"))},pushContext:function(){this.pushStackLiteral("depth"+this.lastContext)},resolvePossibleLambda:function(){this.context.aliases.functionType=
|
||||||
|
'"function"';this.replaceStack(function(a){return"typeof "+a+" === functionType ? "+a+"() : "+a})},lookup:function(a){this.replaceStack(function(b){return b+" == null || "+b+" === false ? "+b+" : "+this.nameLookup(b,a,"context")})},lookupData:function(a){this.pushStack(this.nameLookup("data",a,"data"))},pushStringParam:function(a){this.pushStackLiteral("depth"+this.lastContext);this.pushString(a)},pushString:function(a){this.pushStackLiteral(this.quotedString(a))},push:function(a){this.pushStack(a)},
|
||||||
|
pushLiteral:function(a){this.pushStackLiteral(a)},pushProgram:function(a){a!=null?this.pushStackLiteral(this.programExpression(a)):this.pushStackLiteral(null)},invokeHelper:function(a,b){this.context.aliases.helperMissing="helpers.helperMissing";var e=this.lastHelper=this.setupHelper(a,b);this.register("foundHelper",e.name);this.pushStack("foundHelper ? foundHelper.call("+e.callParams+") : helperMissing.call("+e.helperMissingParams+")")},invokeKnownHelper:function(a,b){var e=this.setupHelper(a,b);
|
||||||
|
this.pushStack(e.name+".call("+e.callParams+")")},invokeAmbiguous:function(a){this.context.aliases.functionType='"function"';this.pushStackLiteral("{}");var b=this.setupHelper(0,a);this.register("foundHelper",this.lastHelper=this.nameLookup("helpers",a,"helper"));a=this.nameLookup("depth"+this.lastContext,a,"context");var e=this.nextStack();this.source.push("if (foundHelper) { "+e+" = foundHelper.call("+b.callParams+"); }");this.source.push("else { "+e+" = "+a+"; "+e+" = typeof "+e+" === functionType ? "+
|
||||||
|
e+"() : "+e+"; }")},invokePartial:function(a){a=[this.nameLookup("partials",a,"partial"),"'"+a+"'",this.popStack(),"helpers","partials"];this.options.data&&a.push("data");this.context.aliases.self="this";this.pushStack("self.invokePartial("+a.join(", ")+");")},assignToHash:function(a){var b=this.popStack();this.source.push(this.topStack()+"['"+a+"'] = "+b+";")},compiler:j,compileChildren:function(a,b){for(var e=a.children,k,l,m=0,s=e.length;m<s;m++){k=e[m];l=new this.compiler;this.context.programs.push("");
|
||||||
|
var r=this.context.programs.length;k.index=r;k.name="program"+r;this.context.programs[r]=l.compile(k,b,this.context)}},programExpression:function(a){this.context.aliases.self="this";if(a==null)return"self.noop";var b=this.environment.children[a];a=b.depths.list;for(var e=[b.index,b.name,"data"],k=0,l=a.length;k<l;k++){b=a[k];b===1?e.push("depth0"):e.push("depth"+(b-1))}if(a.length===0)return"self.program("+e.join(", ")+")";else{e.shift();return"self.programWithDepth("+e.join(", ")+")"}},register:function(a,
|
||||||
|
b){this.useRegister(a);this.source.push(a+" = "+b+";")},useRegister:function(a){if(!this.registers[a]){this.registers[a]=true;this.registers.list.push(a)}},pushStackLiteral:function(a){this.compileStack.push(new h(a));return a},pushStack:function(a){this.source.push(this.incrStack()+" = "+a+";");this.compileStack.push("stack"+this.stackSlot);return"stack"+this.stackSlot},replaceStack:function(a){a=a.call(this,this.topStack());this.source.push(this.topStack()+" = "+a+";");return"stack"+this.stackSlot},
|
||||||
|
nextStack:function(){var a=this.incrStack();this.compileStack.push("stack"+this.stackSlot);return a},incrStack:function(){this.stackSlot++;this.stackSlot>this.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;m<a;m++){l=this.popStack();b.push(l);this.options.stringParams&&k.push(this.popStack())}this.options.stringParams&&e.push("contexts:["+k.join(",")+"]");this.options.data&&e.push("data:data");b.push("{"+e.join(",")+"}");return b.join(", ")}};for(var c="break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield".split(" "),
|
||||||
|
d=j.RESERVED_WORDS={},g=0,i=c.length;g<i;g++)d[c[g]]=true;j.isValidJavaScriptVariableName=function(a){if(!j.RESERVED_WORDS[a]&&/^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(a))return true;return false}})(Handlebars.Compiler,Handlebars.JavaScriptCompiler);Handlebars.precompile=function(f,j){j=j||{};var h=Handlebars.parse(f);h=(new Handlebars.Compiler).compile(h,j);return(new Handlebars.JavaScriptCompiler).compile(h,j)};
|
||||||
|
Handlebars.compile=function(f,j){j=j||{};var h;return function(c,d){if(!h){var g=Handlebars.parse(f);g=(new Handlebars.Compiler).compile(g,j);g=(new Handlebars.JavaScriptCompiler).compile(g,j,undefined,true);h=Handlebars.template(g)}return h.call(this,c,d)}};
|
||||||
|
Handlebars.VM={template:function(f){var j={escapeExpression:Handlebars.Utils.escapeExpression,invokePartial:Handlebars.VM.invokePartial,programs:[],program:function(h,c,d){var g=this.programs[h];if(d)return Handlebars.VM.program(c,d);else{g||(g=this.programs[h]=Handlebars.VM.program(c));return g}},programWithDepth:Handlebars.VM.programWithDepth,noop:Handlebars.VM.noop};return function(h,c){c=c||{};return f.call(j,Handlebars,h,c.helpers,c.partials,c.data)}},programWithDepth:function(f,j){var h=Array.prototype.slice.call(arguments,
|
||||||
|
2);return function(c,d){d=d||{};return f.apply(this,[c,d.data||j].concat(h))}},program:function(f,j){return function(h,c){c=c||{};return f(h,c.data||j)}},noop:function(){return""},invokePartial:function(f,j,h,c,d,g){c={helpers:c,partials:d,data:g};if(f===undefined)throw new Handlebars.Exception("The partial "+j+" could not be found");else if(f instanceof Function)return f(h,c);else if(Handlebars.compile){d[j]=Handlebars.compile(f,{data:g!==undefined});return d[j](h,c)}else throw new Handlebars.Exception("The partial "+
|
||||||
|
j+" could not be compiled when running in runtime-only mode");}};Handlebars.template=Handlebars.VM.template;
|
1920
src/messenger/webim/js/source/handlebars.js
Normal file
1920
src/messenger/webim/js/source/handlebars.js
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user