~andreserl/maas/packaging_precise_rebase

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/handlebars-compiler/handlebars-compiler-debug.js

  • Committer: Andres Rodriguez
  • Date: 2013-03-20 18:12:30 UTC
  • mfrom: (145.2.22 precise.sru)
  • Revision ID: andreserl@ubuntu.com-20130320181230-6l5guc0nhlv2z4p7
Re-base againts latest quantal released branch towards SRU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.1 (build 22)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('handlebars-compiler', function(Y) {
 
8
 
 
9
/*!
 
10
Handlebars.js - Copyright (C) 2011 Yehuda Katz
 
11
https://raw.github.com/wycats/handlebars.js/master/LICENSE
 
12
*/
 
13
// This file contains code that will be inserted at the beginning of the
 
14
// handlebars-compiler module.
 
15
 
 
16
// This is necessary because the Y.Handlebars object is created in the
 
17
// handlebars-base module, but the native Handlebars code expects to use a local
 
18
// Handlebars reference.
 
19
var Handlebars = Y.Handlebars;
 
20
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
 
21
 
 
22
/* Jison generated parser */
 
23
var handlebars = (function(){
 
24
 
 
25
var parser = {trace: function trace() { },
 
26
yy: {},
 
27
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,"param":27,"STRING":28,"INTEGER":29,"BOOLEAN":30,"hashSegments":31,"hashSegment":32,"ID":33,"EQUALS":34,"pathSegments":35,"SEP":36,"$accept":0,"$end":1},
 
28
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",28:"STRING",29:"INTEGER",30:"BOOLEAN",33:"ID",34:"EQUALS",36:"SEP"},
 
29
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],[25,2],[25,1],[27,1],[27,1],[27,1],[27,1],[26,1],[31,2],[31,1],[32,3],[32,3],[32,3],[32,3],[21,1],[35,3],[35,1]],
 
30
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
 
31
 
 
32
var $0 = $$.length - 1;
 
33
switch (yystate) {
 
34
case 1: return $$[$0-1]; 
 
35
break;
 
36
case 2: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]); 
 
37
break;
 
38
case 3: this.$ = new yy.ProgramNode($$[$0]); 
 
39
break;
 
40
case 4: this.$ = new yy.ProgramNode([]); 
 
41
break;
 
42
case 5: this.$ = [$$[$0]]; 
 
43
break;
 
44
case 6: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; 
 
45
break;
 
46
case 7: this.$ = new yy.InverseNode($$[$0-2], $$[$0-1], $$[$0]); 
 
47
break;
 
48
case 8: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0]); 
 
49
break;
 
50
case 9: this.$ = $$[$0]; 
 
51
break;
 
52
case 10: this.$ = $$[$0]; 
 
53
break;
 
54
case 11: this.$ = new yy.ContentNode($$[$0]); 
 
55
break;
 
56
case 12: this.$ = new yy.CommentNode($$[$0]); 
 
57
break;
 
58
case 13: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]); 
 
59
break;
 
60
case 14: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]); 
 
61
break;
 
62
case 15: this.$ = $$[$0-1]; 
 
63
break;
 
64
case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]); 
 
65
break;
 
66
case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true); 
 
67
break;
 
68
case 18: this.$ = new yy.PartialNode($$[$0-1]); 
 
69
break;
 
70
case 19: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]); 
 
71
break;
 
72
case 20: 
 
73
break;
 
74
case 21: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]]; 
 
75
break;
 
76
case 22: this.$ = [[$$[$0-1]].concat($$[$0]), null]; 
 
77
break;
 
78
case 23: this.$ = [[$$[$0-1]], $$[$0]]; 
 
79
break;
 
80
case 24: this.$ = [[$$[$0]], null]; 
 
81
break;
 
82
case 25: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; 
 
83
break;
 
84
case 26: this.$ = [$$[$0]]; 
 
85
break;
 
86
case 27: this.$ = $$[$0]; 
 
87
break;
 
88
case 28: this.$ = new yy.StringNode($$[$0]); 
 
89
break;
 
90
case 29: this.$ = new yy.IntegerNode($$[$0]); 
 
91
break;
 
92
case 30: this.$ = new yy.BooleanNode($$[$0]); 
 
93
break;
 
94
case 31: this.$ = new yy.HashNode($$[$0]); 
 
95
break;
 
96
case 32: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; 
 
97
break;
 
98
case 33: this.$ = [$$[$0]]; 
 
99
break;
 
100
case 34: this.$ = [$$[$0-2], $$[$0]]; 
 
101
break;
 
102
case 35: this.$ = [$$[$0-2], new yy.StringNode($$[$0])]; 
 
103
break;
 
104
case 36: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])]; 
 
105
break;
 
106
case 37: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])]; 
 
107
break;
 
108
case 38: this.$ = new yy.IdNode($$[$0]); 
 
109
break;
 
110
case 39: $$[$0-2].push($$[$0]); this.$ = $$[$0-2]; 
 
111
break;
 
112
case 40: this.$ = [$$[$0]]; 
 
113
break;
 
114
}
 
115
},
 
116
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,33:[1,25],35:24},{17:26,21:23,33:[1,25],35:24},{17:27,21:23,33:[1,25],35:24},{17:28,21:23,33:[1,25],35:24},{21:29,33:[1,25],35:24},{1:[2,1]},{6:30,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,31],21:23,33:[1,25],35:24},{10:32,20:[1,33]},{10:34,20:[1,33]},{18:[1,35]},{18:[2,24],21:40,25:36,26:37,27:38,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,38],28:[2,38],29:[2,38],30:[2,38],33:[2,38],36:[1,46]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],36:[2,40]},{18:[1,47]},{18:[1,48]},{18:[1,49]},{18:[1,50],21:51,33:[1,25],35:24},{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:52,33:[1,25],35:24},{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:40,26:53,27:54,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,23]},{18:[2,26],28:[2,26],29:[2,26],30:[2,26],33:[2,26]},{18:[2,31],32:55,33:[1,56]},{18:[2,27],28:[2,27],29:[2,27],30:[2,27],33:[2,27]},{18:[2,28],28:[2,28],29:[2,28],30:[2,28],33:[2,28]},{18:[2,29],28:[2,29],29:[2,29],30:[2,29],33:[2,29]},{18:[2,30],28:[2,30],29:[2,30],30:[2,30],33:[2,30]},{18:[2,33],33:[2,33]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],34:[1,57],36:[2,40]},{33:[1,58]},{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,59]},{18:[1,60]},{18:[2,21]},{18:[2,25],28:[2,25],29:[2,25],30:[2,25],33:[2,25]},{18:[2,32],33:[2,32]},{34:[1,57]},{21:61,28:[1,62],29:[1,63],30:[1,64],33:[1,25],35:24},{18:[2,39],28:[2,39],29:[2,39],30:[2,39],33:[2,39],36:[2,39]},{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,34],33:[2,34]},{18:[2,35],33:[2,35]},{18:[2,36],33:[2,36]},{18:[2,37],33:[2,37]}],
 
117
defaultActions: {16:[2,1],37:[2,23],53:[2,21]},
 
118
parseError: function parseError(str, hash) {
 
119
    throw new Error(str);
 
120
},
 
121
parse: function parse(input) {
 
122
    var self = this,
 
123
        stack = [0],
 
124
        vstack = [null], // semantic value stack
 
125
        lstack = [], // location stack
 
126
        table = this.table,
 
127
        yytext = '',
 
128
        yylineno = 0,
 
129
        yyleng = 0,
 
130
        recovering = 0,
 
131
        TERROR = 2,
 
132
        EOF = 1;
 
133
 
 
134
    //this.reductionCount = this.shiftCount = 0;
 
135
 
 
136
    this.lexer.setInput(input);
 
137
    this.lexer.yy = this.yy;
 
138
    this.yy.lexer = this.lexer;
 
139
    if (typeof this.lexer.yylloc == 'undefined')
 
140
        this.lexer.yylloc = {};
 
141
    var yyloc = this.lexer.yylloc;
 
142
    lstack.push(yyloc);
 
143
 
 
144
    if (typeof this.yy.parseError === 'function')
 
145
        this.parseError = this.yy.parseError;
 
146
 
 
147
    function popStack (n) {
 
148
        stack.length = stack.length - 2*n;
 
149
        vstack.length = vstack.length - n;
 
150
        lstack.length = lstack.length - n;
 
151
    }
 
152
 
 
153
    function lex() {
 
154
        var token;
 
155
        token = self.lexer.lex() || 1; // $end = 1
 
156
        // if token isn't its numeric value, convert
 
157
        if (typeof token !== 'number') {
 
158
            token = self.symbols_[token] || token;
 
159
        }
 
160
        return token;
 
161
    }
 
162
 
 
163
    var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
 
164
    while (true) {
 
165
        // retreive state number from top of stack
 
166
        state = stack[stack.length-1];
 
167
 
 
168
        // use default actions if available
 
169
        if (this.defaultActions[state]) {
 
170
            action = this.defaultActions[state];
 
171
        } else {
 
172
            if (symbol == null)
 
173
                symbol = lex();
 
174
            // read action for current state and first input
 
175
            action = table[state] && table[state][symbol];
 
176
        }
 
177
 
 
178
        // handle parse error
 
179
        _handle_error:
 
180
        if (typeof action === 'undefined' || !action.length || !action[0]) {
 
181
 
 
182
            if (!recovering) {
 
183
                // Report error
 
184
                expected = [];
 
185
                for (p in table[state]) if (this.terminals_[p] && p > 2) {
 
186
                    expected.push("'"+this.terminals_[p]+"'");
 
187
                }
 
188
                var errStr = '';
 
189
                if (this.lexer.showPosition) {
 
190
                    errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
 
191
                } else {
 
192
                    errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
 
193
                                  (symbol == 1 /*EOF*/ ? "end of input" :
 
194
                                              ("'"+(this.terminals_[symbol] || symbol)+"'"));
 
195
                }
 
196
                this.parseError(errStr,
 
197
                    {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
 
198
            }
 
199
 
 
200
            // just recovered from another error
 
201
            if (recovering == 3) {
 
202
                if (symbol == EOF) {
 
203
                    throw new Error(errStr || 'Parsing halted.');
 
204
                }
 
205
 
 
206
                // discard current lookahead and grab another
 
207
                yyleng = this.lexer.yyleng;
 
208
                yytext = this.lexer.yytext;
 
209
                yylineno = this.lexer.yylineno;
 
210
                yyloc = this.lexer.yylloc;
 
211
                symbol = lex();
 
212
            }
 
213
 
 
214
            // try to recover from error
 
215
            while (1) {
 
216
                // check for error recovery rule in this state
 
217
                if ((TERROR.toString()) in table[state]) {
 
218
                    break;
 
219
                }
 
220
                if (state == 0) {
 
221
                    throw new Error(errStr || 'Parsing halted.');
 
222
                }
 
223
                popStack(1);
 
224
                state = stack[stack.length-1];
 
225
            }
 
226
 
 
227
            preErrorSymbol = symbol; // save the lookahead token
 
228
            symbol = TERROR;         // insert generic error symbol as new lookahead
 
229
            state = stack[stack.length-1];
 
230
            action = table[state] && table[state][TERROR];
 
231
            recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
 
232
        }
 
233
 
 
234
        // this shouldn't happen, unless resolve defaults are off
 
235
        if (action[0] instanceof Array && action.length > 1) {
 
236
            throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
 
237
        }
 
238
 
 
239
        switch (action[0]) {
 
240
 
 
241
            case 1: // shift
 
242
                //this.shiftCount++;
 
243
 
 
244
                stack.push(symbol);
 
245
                vstack.push(this.lexer.yytext);
 
246
                lstack.push(this.lexer.yylloc);
 
247
                stack.push(action[1]); // push state
 
248
                symbol = null;
 
249
                if (!preErrorSymbol) { // normal execution/no error
 
250
                    yyleng = this.lexer.yyleng;
 
251
                    yytext = this.lexer.yytext;
 
252
                    yylineno = this.lexer.yylineno;
 
253
                    yyloc = this.lexer.yylloc;
 
254
                    if (recovering > 0)
 
255
                        recovering--;
 
256
                } else { // error just occurred, resume old lookahead f/ before error
 
257
                    symbol = preErrorSymbol;
 
258
                    preErrorSymbol = null;
 
259
                }
 
260
                break;
 
261
 
 
262
            case 2: // reduce
 
263
                //this.reductionCount++;
 
264
 
 
265
                len = this.productions_[action[1]][1];
 
266
 
 
267
                // perform semantic action
 
268
                yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
 
269
                // default location, uses first token for firsts, last for lasts
 
270
                yyval._$ = {
 
271
                    first_line: lstack[lstack.length-(len||1)].first_line,
 
272
                    last_line: lstack[lstack.length-1].last_line,
 
273
                    first_column: lstack[lstack.length-(len||1)].first_column,
 
274
                    last_column: lstack[lstack.length-1].last_column
 
275
                };
 
276
                r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
 
277
 
 
278
                if (typeof r !== 'undefined') {
 
279
                    return r;
 
280
                }
 
281
 
 
282
                // pop off stack
 
283
                if (len) {
 
284
                    stack = stack.slice(0,-1*len*2);
 
285
                    vstack = vstack.slice(0, -1*len);
 
286
                    lstack = lstack.slice(0, -1*len);
 
287
                }
 
288
 
 
289
                stack.push(this.productions_[action[1]][0]);    // push nonterminal (reduce)
 
290
                vstack.push(yyval.$);
 
291
                lstack.push(yyval._$);
 
292
                // goto new state = table[STATE][NONTERMINAL]
 
293
                newState = table[stack[stack.length-2]][stack[stack.length-1]];
 
294
                stack.push(newState);
 
295
                break;
 
296
 
 
297
            case 3: // accept
 
298
                return true;
 
299
        }
 
300
 
 
301
    }
 
302
 
 
303
    return true;
 
304
}};/* Jison generated lexer */
 
305
var lexer = (function(){
 
306
 
 
307
var lexer = ({EOF:1,
 
308
parseError:function parseError(str, hash) {
 
309
        if (this.yy.parseError) {
 
310
            this.yy.parseError(str, hash);
 
311
        } else {
 
312
            throw new Error(str);
 
313
        }
 
314
    },
 
315
setInput:function (input) {
 
316
        this._input = input;
 
317
        this._more = this._less = this.done = false;
 
318
        this.yylineno = this.yyleng = 0;
 
319
        this.yytext = this.matched = this.match = '';
 
320
        this.conditionStack = ['INITIAL'];
 
321
        this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
 
322
        return this;
 
323
    },
 
324
input:function () {
 
325
        var ch = this._input[0];
 
326
        this.yytext+=ch;
 
327
        this.yyleng++;
 
328
        this.match+=ch;
 
329
        this.matched+=ch;
 
330
        var lines = ch.match(/\n/);
 
331
        if (lines) this.yylineno++;
 
332
        this._input = this._input.slice(1);
 
333
        return ch;
 
334
    },
 
335
unput:function (ch) {
 
336
        this._input = ch + this._input;
 
337
        return this;
 
338
    },
 
339
more:function () {
 
340
        this._more = true;
 
341
        return this;
 
342
    },
 
343
pastInput:function () {
 
344
        var past = this.matched.substr(0, this.matched.length - this.match.length);
 
345
        return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
 
346
    },
 
347
upcomingInput:function () {
 
348
        var next = this.match;
 
349
        if (next.length < 20) {
 
350
            next += this._input.substr(0, 20-next.length);
 
351
        }
 
352
        return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
 
353
    },
 
354
showPosition:function () {
 
355
        var pre = this.pastInput();
 
356
        var c = new Array(pre.length + 1).join("-");
 
357
        return pre + this.upcomingInput() + "\n" + c+"^";
 
358
    },
 
359
next:function () {
 
360
        if (this.done) {
 
361
            return this.EOF;
 
362
        }
 
363
        if (!this._input) this.done = true;
 
364
 
 
365
        var token,
 
366
            match,
 
367
            col,
 
368
            lines;
 
369
        if (!this._more) {
 
370
            this.yytext = '';
 
371
            this.match = '';
 
372
        }
 
373
        var rules = this._currentRules();
 
374
        for (var i=0;i < rules.length; i++) {
 
375
            match = this._input.match(this.rules[rules[i]]);
 
376
            if (match) {
 
377
                lines = match[0].match(/\n.*/g);
 
378
                if (lines) this.yylineno += lines.length;
 
379
                this.yylloc = {first_line: this.yylloc.last_line,
 
380
                               last_line: this.yylineno+1,
 
381
                               first_column: this.yylloc.last_column,
 
382
                               last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}
 
383
                this.yytext += match[0];
 
384
                this.match += match[0];
 
385
                this.matches = match;
 
386
                this.yyleng = this.yytext.length;
 
387
                this._more = false;
 
388
                this._input = this._input.slice(match[0].length);
 
389
                this.matched += match[0];
 
390
                token = this.performAction.call(this, this.yy, this, rules[i],this.conditionStack[this.conditionStack.length-1]);
 
391
                if (token) return token;
 
392
                else return;
 
393
            }
 
394
        }
 
395
        if (this._input === "") {
 
396
            return this.EOF;
 
397
        } else {
 
398
            this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), 
 
399
                    {text: "", token: null, line: this.yylineno});
 
400
        }
 
401
    },
 
402
lex:function lex() {
 
403
        var r = this.next();
 
404
        if (typeof r !== 'undefined') {
 
405
            return r;
 
406
        } else {
 
407
            return this.lex();
 
408
        }
 
409
    },
 
410
begin:function begin(condition) {
 
411
        this.conditionStack.push(condition);
 
412
    },
 
413
popState:function popState() {
 
414
        return this.conditionStack.pop();
 
415
    },
 
416
_currentRules:function _currentRules() {
 
417
        return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
 
418
    },
 
419
topState:function () {
 
420
        return this.conditionStack[this.conditionStack.length-2];
 
421
    },
 
422
pushState:function begin(condition) {
 
423
        this.begin(condition);
 
424
    }});
 
425
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
 
426
 
 
427
var YYSTATE=YY_START
 
428
switch($avoiding_name_collisions) {
 
429
case 0:
 
430
                                   if(yy_.yytext.slice(-1) !== "\\") this.begin("mu");
 
431
                                   if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu");
 
432
                                   if(yy_.yytext) return 14;
 
433
                                 
 
434
break;
 
435
case 1: return 14; 
 
436
break;
 
437
case 2: this.popState(); return 14; 
 
438
break;
 
439
case 3: return 24; 
 
440
break;
 
441
case 4: return 16; 
 
442
break;
 
443
case 5: return 20; 
 
444
break;
 
445
case 6: return 19; 
 
446
break;
 
447
case 7: return 19; 
 
448
break;
 
449
case 8: return 23; 
 
450
break;
 
451
case 9: return 23; 
 
452
break;
 
453
case 10: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15; 
 
454
break;
 
455
case 11: return 22; 
 
456
break;
 
457
case 12: return 34; 
 
458
break;
 
459
case 13: return 33; 
 
460
break;
 
461
case 14: return 33; 
 
462
break;
 
463
case 15: return 36; 
 
464
break;
 
465
case 16: /*ignore whitespace*/ 
 
466
break;
 
467
case 17: this.popState(); return 18; 
 
468
break;
 
469
case 18: this.popState(); return 18; 
 
470
break;
 
471
case 19: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 28; 
 
472
break;
 
473
case 20: return 30; 
 
474
break;
 
475
case 21: return 30; 
 
476
break;
 
477
case 22: return 29; 
 
478
break;
 
479
case 23: return 33; 
 
480
break;
 
481
case 24: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 33; 
 
482
break;
 
483
case 25: return 'INVALID'; 
 
484
break;
 
485
case 26: return 5; 
 
486
break;
 
487
}
 
488
};
 
489
lexer.rules = [/^[^\x00]*?(?=(\{\{))/,/^[^\x00]+/,/^[^\x00]{2,}?(?=(\{\{))/,/^\{\{>/,/^\{\{#/,/^\{\{\//,/^\{\{\^/,/^\{\{\s*else\b/,/^\{\{\{/,/^\{\{&/,/^\{\{![\s\S]*?\}\}/,/^\{\{/,/^=/,/^\.(?=[} ])/,/^\.\./,/^[\/.]/,/^\s+/,/^\}\}\}/,/^\}\}/,/^"(\\["]|[^"])*"/,/^true(?=[}\s])/,/^false(?=[}\s])/,/^[0-9]+(?=[}\s])/,/^[a-zA-Z0-9_$-]+(?=[=}\s\/.])/,/^\[[^\]]*\]/,/^./,/^$/];
 
490
lexer.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],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"INITIAL":{"rules":[0,1,26],"inclusive":true}};return lexer;})()
 
491
parser.lexer = lexer;
 
492
return parser;
 
493
})();
 
494
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
 
495
exports.parser = handlebars;
 
496
exports.parse = function () { return handlebars.parse.apply(handlebars, arguments); }
 
497
exports.main = function commonjsMain(args) {
 
498
    if (!args[1])
 
499
        throw new Error('Usage: '+args[0]+' FILE');
 
500
    if (typeof process !== 'undefined') {
 
501
        var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
 
502
    } else {
 
503
        var cwd = require("file").path(require("file").cwd());
 
504
        var source = cwd.join(args[1]).read({charset: "utf-8"});
 
505
    }
 
506
    return exports.parser.parse(source);
 
507
}
 
508
if (typeof module !== 'undefined' && require.main === module) {
 
509
  exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
 
510
}
 
511
};
 
512
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
 
513
 
 
514
// BEGIN(BROWSER)
 
515
Handlebars.Parser = handlebars;
 
516
 
 
517
Handlebars.parse = function(string) {
 
518
  Handlebars.Parser.yy = Handlebars.AST;
 
519
  return Handlebars.Parser.parse(string);
 
520
};
 
521
 
 
522
Handlebars.print = function(ast) {
 
523
  return new Handlebars.PrintVisitor().accept(ast);
 
524
};
 
525
 
 
526
Handlebars.logger = {
 
527
  DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
 
528
 
 
529
  // override in the host environment
 
530
  log: function(level, str) {}
 
531
};
 
532
 
 
533
Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
 
534
 
 
535
// END(BROWSER)
 
536
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
 
537
 
 
538
// BEGIN(BROWSER)
 
539
(function() {
 
540
 
 
541
  Handlebars.AST = {};
 
542
 
 
543
  Handlebars.AST.ProgramNode = function(statements, inverse) {
 
544
    this.type = "program";
 
545
    this.statements = statements;
 
546
    if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); }
 
547
  };
 
548
 
 
549
  Handlebars.AST.MustacheNode = function(params, hash, unescaped) {
 
550
    this.type = "mustache";
 
551
    this.id = params[0];
 
552
    this.params = params.slice(1);
 
553
    this.hash = hash;
 
554
    this.escaped = !unescaped;
 
555
  };
 
556
 
 
557
  Handlebars.AST.PartialNode = function(id, context) {
 
558
    this.type    = "partial";
 
559
 
 
560
    // TODO: disallow complex IDs
 
561
 
 
562
    this.id      = id;
 
563
    this.context = context;
 
564
  };
 
565
 
 
566
  var verifyMatch = function(open, close) {
 
567
    if(open.original !== close.original) {
 
568
      throw new Handlebars.Exception(open.original + " doesn't match " + close.original);
 
569
    }
 
570
  };
 
571
 
 
572
  Handlebars.AST.BlockNode = function(mustache, program, close) {
 
573
    verifyMatch(mustache.id, close);
 
574
    this.type = "block";
 
575
    this.mustache = mustache;
 
576
    this.program  = program;
 
577
  };
 
578
 
 
579
  Handlebars.AST.InverseNode = function(mustache, program, close) {
 
580
    verifyMatch(mustache.id, close);
 
581
    this.type = "inverse";
 
582
    this.mustache = mustache;
 
583
    this.program  = program;
 
584
  };
 
585
 
 
586
  Handlebars.AST.ContentNode = function(string) {
 
587
    this.type = "content";
 
588
    this.string = string;
 
589
  };
 
590
 
 
591
  Handlebars.AST.HashNode = function(pairs) {
 
592
    this.type = "hash";
 
593
    this.pairs = pairs;
 
594
  };
 
595
 
 
596
  Handlebars.AST.IdNode = function(parts) {
 
597
    this.type = "ID";
 
598
    this.original = parts.join(".");
 
599
 
 
600
    var dig = [], depth = 0;
 
601
 
 
602
    for(var i=0,l=parts.length; i<l; i++) {
 
603
      var part = parts[i];
 
604
 
 
605
      if(part === "..") { depth++; }
 
606
      else if(part === "." || part === "this") { this.isScoped = true; }
 
607
      else { dig.push(part); }
 
608
    }
 
609
 
 
610
    this.parts    = dig;
 
611
    this.string   = dig.join('.');
 
612
    this.depth    = depth;
 
613
    this.isSimple = (dig.length === 1) && (depth === 0);
 
614
  };
 
615
 
 
616
  Handlebars.AST.StringNode = function(string) {
 
617
    this.type = "STRING";
 
618
    this.string = string;
 
619
  };
 
620
 
 
621
  Handlebars.AST.IntegerNode = function(integer) {
 
622
    this.type = "INTEGER";
 
623
    this.integer = integer;
 
624
  };
 
625
 
 
626
  Handlebars.AST.BooleanNode = function(bool) {
 
627
    this.type = "BOOLEAN";
 
628
    this.bool = bool;
 
629
  };
 
630
 
 
631
  Handlebars.AST.CommentNode = function(comment) {
 
632
    this.type = "comment";
 
633
    this.comment = comment;
 
634
  };
 
635
 
 
636
})();
 
637
// END(BROWSER)
 
638
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
 
639
 
 
640
// BEGIN(BROWSER)
 
641
 
 
642
/*jshint eqnull:true*/
 
643
Handlebars.Compiler = function() {};
 
644
Handlebars.JavaScriptCompiler = function() {};
 
645
 
 
646
(function(Compiler, JavaScriptCompiler) {
 
647
  Compiler.OPCODE_MAP = {
 
648
    appendContent: 1,
 
649
    getContext: 2,
 
650
    lookupWithHelpers: 3,
 
651
    lookup: 4,
 
652
    append: 5,
 
653
    invokeMustache: 6,
 
654
    appendEscaped: 7,
 
655
    pushString: 8,
 
656
    truthyOrFallback: 9,
 
657
    functionOrFallback: 10,
 
658
    invokeProgram: 11,
 
659
    invokePartial: 12,
 
660
    push: 13,
 
661
    assignToHash: 15,
 
662
    pushStringParam: 16
 
663
  };
 
664
 
 
665
  Compiler.MULTI_PARAM_OPCODES = {
 
666
    appendContent: 1,
 
667
    getContext: 1,
 
668
    lookupWithHelpers: 2,
 
669
    lookup: 1,
 
670
    invokeMustache: 3,
 
671
    pushString: 1,
 
672
    truthyOrFallback: 1,
 
673
    functionOrFallback: 1,
 
674
    invokeProgram: 3,
 
675
    invokePartial: 1,
 
676
    push: 1,
 
677
    assignToHash: 1,
 
678
    pushStringParam: 1
 
679
  };
 
680
 
 
681
  Compiler.DISASSEMBLE_MAP = {};
 
682
 
 
683
  for(var prop in Compiler.OPCODE_MAP) {
 
684
    var value = Compiler.OPCODE_MAP[prop];
 
685
    Compiler.DISASSEMBLE_MAP[value] = prop;
 
686
  }
 
687
 
 
688
  Compiler.multiParamSize = function(code) {
 
689
    return Compiler.MULTI_PARAM_OPCODES[Compiler.DISASSEMBLE_MAP[code]];
 
690
  };
 
691
 
 
692
  Compiler.prototype = {
 
693
    compiler: Compiler,
 
694
 
 
695
    disassemble: function() {
 
696
      var opcodes = this.opcodes, opcode, nextCode;
 
697
      var out = [], str, name, value;
 
698
 
 
699
      for(var i=0, l=opcodes.length; i<l; i++) {
 
700
        opcode = opcodes[i];
 
701
 
 
702
        if(opcode === 'DECLARE') {
 
703
          name = opcodes[++i];
 
704
          value = opcodes[++i];
 
705
          out.push("DECLARE " + name + " = " + value);
 
706
        } else {
 
707
          str = Compiler.DISASSEMBLE_MAP[opcode];
 
708
 
 
709
          var extraParams = Compiler.multiParamSize(opcode);
 
710
          var codes = [];
 
711
 
 
712
          for(var j=0; j<extraParams; j++) {
 
713
            nextCode = opcodes[++i];
 
714
 
 
715
            if(typeof nextCode === "string") {
 
716
              nextCode = "\"" + nextCode.replace("\n", "\\n") + "\"";
 
717
            }
 
718
 
 
719
            codes.push(nextCode);
 
720
          }
 
721
 
 
722
          str = str + " " + codes.join(" ");
 
723
 
 
724
          out.push(str);
 
725
        }
 
726
      }
 
727
 
 
728
      return out.join("\n");
 
729
    },
 
730
 
 
731
    guid: 0,
 
732
 
 
733
    compile: function(program, options) {
 
734
      this.children = [];
 
735
      this.depths = {list: []};
 
736
      this.options = options;
 
737
 
 
738
      // These changes will propagate to the other compiler components
 
739
      var knownHelpers = this.options.knownHelpers;
 
740
      this.options.knownHelpers = {
 
741
        'helperMissing': true,
 
742
        'blockHelperMissing': true,
 
743
        'each': true,
 
744
        'if': true,
 
745
        'unless': true,
 
746
        'with': true,
 
747
        'log': true
 
748
      };
 
749
      if (knownHelpers) {
 
750
        for (var name in knownHelpers) {
 
751
          this.options.knownHelpers[name] = knownHelpers[name];
 
752
        }
 
753
      }
 
754
 
 
755
      return this.program(program);
 
756
    },
 
757
 
 
758
    accept: function(node) {
 
759
      return this[node.type](node);
 
760
    },
 
761
 
 
762
    program: function(program) {
 
763
      var statements = program.statements, statement;
 
764
      this.opcodes = [];
 
765
 
 
766
      for(var i=0, l=statements.length; i<l; i++) {
 
767
        statement = statements[i];
 
768
        this[statement.type](statement);
 
769
      }
 
770
      this.isSimple = l === 1;
 
771
 
 
772
      this.depths.list = this.depths.list.sort(function(a, b) {
 
773
        return a - b;
 
774
      });
 
775
 
 
776
      return this;
 
777
    },
 
778
 
 
779
    compileProgram: function(program) {
 
780
      var result = new this.compiler().compile(program, this.options);
 
781
      var guid = this.guid++, depth;
 
782
 
 
783
      this.usePartial = this.usePartial || result.usePartial;
 
784
 
 
785
      this.children[guid] = result;
 
786
 
 
787
      for(var i=0, l=result.depths.list.length; i<l; i++) {
 
788
        depth = result.depths.list[i];
 
789
 
 
790
        if(depth < 2) { continue; }
 
791
        else { this.addDepth(depth - 1); }
 
792
      }
 
793
 
 
794
      return guid;
 
795
    },
 
796
 
 
797
    block: function(block) {
 
798
      var mustache = block.mustache;
 
799
      var depth, child, inverse, inverseGuid;
 
800
 
 
801
      var params = this.setupStackForMustache(mustache);
 
802
 
 
803
      var programGuid = this.compileProgram(block.program);
 
804
 
 
805
      if(block.program.inverse) {
 
806
        inverseGuid = this.compileProgram(block.program.inverse);
 
807
        this.declare('inverse', inverseGuid);
 
808
      }
 
809
 
 
810
      this.opcode('invokeProgram', programGuid, params.length, !!mustache.hash);
 
811
      this.declare('inverse', null);
 
812
      this.opcode('append');
 
813
    },
 
814
 
 
815
    inverse: function(block) {
 
816
      var params = this.setupStackForMustache(block.mustache);
 
817
 
 
818
      var programGuid = this.compileProgram(block.program);
 
819
 
 
820
      this.declare('inverse', programGuid);
 
821
 
 
822
      this.opcode('invokeProgram', null, params.length, !!block.mustache.hash);
 
823
      this.declare('inverse', null);
 
824
      this.opcode('append');
 
825
    },
 
826
 
 
827
    hash: function(hash) {
 
828
      var pairs = hash.pairs, pair, val;
 
829
 
 
830
      this.opcode('push', '{}');
 
831
 
 
832
      for(var i=0, l=pairs.length; i<l; i++) {
 
833
        pair = pairs[i];
 
834
        val  = pair[1];
 
835
 
 
836
        this.accept(val);
 
837
        this.opcode('assignToHash', pair[0]);
 
838
      }
 
839
    },
 
840
 
 
841
    partial: function(partial) {
 
842
      var id = partial.id;
 
843
      this.usePartial = true;
 
844
 
 
845
      if(partial.context) {
 
846
        this.ID(partial.context);
 
847
      } else {
 
848
        this.opcode('push', 'depth0');
 
849
      }
 
850
 
 
851
      this.opcode('invokePartial', id.original);
 
852
      this.opcode('append');
 
853
    },
 
854
 
 
855
    content: function(content) {
 
856
      this.opcode('appendContent', content.string);
 
857
    },
 
858
 
 
859
    mustache: function(mustache) {
 
860
      var params = this.setupStackForMustache(mustache);
 
861
 
 
862
      this.opcode('invokeMustache', params.length, mustache.id.original, !!mustache.hash);
 
863
 
 
864
      if(mustache.escaped && !this.options.noEscape) {
 
865
        this.opcode('appendEscaped');
 
866
      } else {
 
867
        this.opcode('append');
 
868
      }
 
869
    },
 
870
 
 
871
    ID: function(id) {
 
872
      this.addDepth(id.depth);
 
873
 
 
874
      this.opcode('getContext', id.depth);
 
875
 
 
876
      this.opcode('lookupWithHelpers', id.parts[0] || null, id.isScoped || false);
 
877
 
 
878
      for(var i=1, l=id.parts.length; i<l; i++) {
 
879
        this.opcode('lookup', id.parts[i]);
 
880
      }
 
881
    },
 
882
 
 
883
    STRING: function(string) {
 
884
      this.opcode('pushString', string.string);
 
885
    },
 
886
 
 
887
    INTEGER: function(integer) {
 
888
      this.opcode('push', integer.integer);
 
889
    },
 
890
 
 
891
    BOOLEAN: function(bool) {
 
892
      this.opcode('push', bool.bool);
 
893
    },
 
894
 
 
895
    comment: function() {},
 
896
 
 
897
    // HELPERS
 
898
    pushParams: function(params) {
 
899
      var i = params.length, param;
 
900
 
 
901
      while(i--) {
 
902
        param = params[i];
 
903
 
 
904
        if(this.options.stringParams) {
 
905
          if(param.depth) {
 
906
            this.addDepth(param.depth);
 
907
          }
 
908
 
 
909
          this.opcode('getContext', param.depth || 0);
 
910
          this.opcode('pushStringParam', param.string);
 
911
        } else {
 
912
          this[param.type](param);
 
913
        }
 
914
      }
 
915
    },
 
916
 
 
917
    opcode: function(name, val1, val2, val3) {
 
918
      this.opcodes.push(Compiler.OPCODE_MAP[name]);
 
919
      if(val1 !== undefined) { this.opcodes.push(val1); }
 
920
      if(val2 !== undefined) { this.opcodes.push(val2); }
 
921
      if(val3 !== undefined) { this.opcodes.push(val3); }
 
922
    },
 
923
 
 
924
    declare: function(name, value) {
 
925
      this.opcodes.push('DECLARE');
 
926
      this.opcodes.push(name);
 
927
      this.opcodes.push(value);
 
928
    },
 
929
 
 
930
    addDepth: function(depth) {
 
931
      if(depth === 0) { return; }
 
932
 
 
933
      if(!this.depths[depth]) {
 
934
        this.depths[depth] = true;
 
935
        this.depths.list.push(depth);
 
936
      }
 
937
    },
 
938
 
 
939
    setupStackForMustache: function(mustache) {
 
940
      var params = mustache.params;
 
941
 
 
942
      this.pushParams(params);
 
943
 
 
944
      if(mustache.hash) {
 
945
        this.hash(mustache.hash);
 
946
      }
 
947
 
 
948
      this.ID(mustache.id);
 
949
 
 
950
      return params;
 
951
    }
 
952
  };
 
953
 
 
954
  JavaScriptCompiler.prototype = {
 
955
    // PUBLIC API: You can override these methods in a subclass to provide
 
956
    // alternative compiled forms for name lookup and buffering semantics
 
957
    nameLookup: function(parent, name, type) {
 
958
      if (/^[0-9]+$/.test(name)) {
 
959
        return parent + "[" + name + "]";
 
960
      } else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
 
961
        return parent + "." + name;
 
962
      }
 
963
      else {
 
964
        return parent + "['" + name + "']";
 
965
      }
 
966
    },
 
967
 
 
968
    appendToBuffer: function(string) {
 
969
      if (this.environment.isSimple) {
 
970
        return "return " + string + ";";
 
971
      } else {
 
972
        return "buffer += " + string + ";";
 
973
      }
 
974
    },
 
975
 
 
976
    initializeBuffer: function() {
 
977
      return this.quotedString("");
 
978
    },
 
979
 
 
980
    namespace: "Handlebars",
 
981
    // END PUBLIC API
 
982
 
 
983
    compile: function(environment, options, context, asObject) {
 
984
      this.environment = environment;
 
985
      this.options = options || {};
 
986
 
 
987
      this.name = this.environment.name;
 
988
      this.isChild = !!context;
 
989
      this.context = context || {
 
990
        programs: [],
 
991
        aliases: { self: 'this' },
 
992
        registers: {list: []}
 
993
      };
 
994
 
 
995
      this.preamble();
 
996
 
 
997
      this.stackSlot = 0;
 
998
      this.stackVars = [];
 
999
 
 
1000
      this.compileChildren(environment, options);
 
1001
 
 
1002
      var opcodes = environment.opcodes, opcode;
 
1003
 
 
1004
      this.i = 0;
 
1005
 
 
1006
      for(l=opcodes.length; this.i<l; this.i++) {
 
1007
        opcode = this.nextOpcode(0);
 
1008
 
 
1009
        if(opcode[0] === 'DECLARE') {
 
1010
          this.i = this.i + 2;
 
1011
          this[opcode[1]] = opcode[2];
 
1012
        } else {
 
1013
          this.i = this.i + opcode[1].length;
 
1014
          this[opcode[0]].apply(this, opcode[1]);
 
1015
        }
 
1016
      }
 
1017
 
 
1018
      return this.createFunctionContext(asObject);
 
1019
    },
 
1020
 
 
1021
    nextOpcode: function(n) {
 
1022
      var opcodes = this.environment.opcodes, opcode = opcodes[this.i + n], name, val;
 
1023
      var extraParams, codes;
 
1024
 
 
1025
      if(opcode === 'DECLARE') {
 
1026
        name = opcodes[this.i + 1];
 
1027
        val  = opcodes[this.i + 2];
 
1028
        return ['DECLARE', name, val];
 
1029
      } else {
 
1030
        name = Compiler.DISASSEMBLE_MAP[opcode];
 
1031
 
 
1032
        extraParams = Compiler.multiParamSize(opcode);
 
1033
        codes = [];
 
1034
 
 
1035
        for(var j=0; j<extraParams; j++) {
 
1036
          codes.push(opcodes[this.i + j + 1 + n]);
 
1037
        }
 
1038
 
 
1039
        return [name, codes];
 
1040
      }
 
1041
    },
 
1042
 
 
1043
    eat: function(opcode) {
 
1044
      this.i = this.i + opcode.length;
 
1045
    },
 
1046
 
 
1047
    preamble: function() {
 
1048
      var out = [];
 
1049
 
 
1050
      // this register will disambiguate helper lookup from finding a function in
 
1051
      // a context. This is necessary for mustache compatibility, which requires
 
1052
      // that context functions in blocks are evaluated by blockHelperMissing, and
 
1053
      // then proceed as if the resulting value was provided to blockHelperMissing.
 
1054
      this.useRegister('foundHelper');
 
1055
 
 
1056
      if (!this.isChild) {
 
1057
        var namespace = this.namespace;
 
1058
        var copies = "helpers = helpers || " + namespace + ".helpers;";
 
1059
        if(this.environment.usePartial) { copies = copies + " partials = partials || " + namespace + ".partials;"; }
 
1060
        out.push(copies);
 
1061
      } else {
 
1062
        out.push('');
 
1063
      }
 
1064
 
 
1065
      if (!this.environment.isSimple) {
 
1066
        out.push(", buffer = " + this.initializeBuffer());
 
1067
      } else {
 
1068
        out.push("");
 
1069
      }
 
1070
 
 
1071
      // track the last context pushed into place to allow skipping the
 
1072
      // getContext opcode when it would be a noop
 
1073
      this.lastContext = 0;
 
1074
      this.source = out;
 
1075
    },
 
1076
 
 
1077
    createFunctionContext: function(asObject) {
 
1078
      var locals = this.stackVars;
 
1079
      if (!this.isChild) {
 
1080
        locals = locals.concat(this.context.registers.list);
 
1081
      }
 
1082
 
 
1083
      if(locals.length > 0) {
 
1084
        this.source[1] = this.source[1] + ", " + locals.join(", ");
 
1085
      }
 
1086
 
 
1087
      // Generate minimizer alias mappings
 
1088
      if (!this.isChild) {
 
1089
        var aliases = [];
 
1090
        for (var alias in this.context.aliases) {
 
1091
          this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias];
 
1092
        }
 
1093
      }
 
1094
 
 
1095
      if (this.source[1]) {
 
1096
        this.source[1] = "var " + this.source[1].substring(2) + ";";
 
1097
      }
 
1098
 
 
1099
      // Merge children
 
1100
      if (!this.isChild) {
 
1101
        this.source[1] += '\n' + this.context.programs.join('\n') + '\n';
 
1102
      }
 
1103
 
 
1104
      if (!this.environment.isSimple) {
 
1105
        this.source.push("return buffer;");
 
1106
      }
 
1107
 
 
1108
      var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"];
 
1109
 
 
1110
      for(var i=0, l=this.environment.depths.list.length; i<l; i++) {
 
1111
        params.push("depth" + this.environment.depths.list[i]);
 
1112
      }
 
1113
 
 
1114
      if (asObject) {
 
1115
        params.push(this.source.join("\n  "));
 
1116
 
 
1117
        return Function.apply(this, params);
 
1118
      } else {
 
1119
        var functionSource = 'function ' + (this.name || '') + '(' + params.join(',') + ') {\n  ' + this.source.join("\n  ") + '}';
 
1120
        Handlebars.log(Handlebars.logger.DEBUG, functionSource + "\n\n");
 
1121
        return functionSource;
 
1122
      }
 
1123
    },
 
1124
 
 
1125
    appendContent: function(content) {
 
1126
      this.source.push(this.appendToBuffer(this.quotedString(content)));
 
1127
    },
 
1128
 
 
1129
    append: function() {
 
1130
      var local = this.popStack();
 
1131
      this.source.push("if(" + local + " || " + local + " === 0) { " + this.appendToBuffer(local) + " }");
 
1132
      if (this.environment.isSimple) {
 
1133
        this.source.push("else { " + this.appendToBuffer("''") + " }");
 
1134
      }
 
1135
    },
 
1136
 
 
1137
    appendEscaped: function() {
 
1138
      var opcode = this.nextOpcode(1), extra = "";
 
1139
      this.context.aliases.escapeExpression = 'this.escapeExpression';
 
1140
 
 
1141
      if(opcode[0] === 'appendContent') {
 
1142
        extra = " + " + this.quotedString(opcode[1][0]);
 
1143
        this.eat(opcode);
 
1144
      }
 
1145
 
 
1146
      this.source.push(this.appendToBuffer("escapeExpression(" + this.popStack() + ")" + extra));
 
1147
    },
 
1148
 
 
1149
    getContext: function(depth) {
 
1150
      if(this.lastContext !== depth) {
 
1151
        this.lastContext = depth;
 
1152
      }
 
1153
    },
 
1154
 
 
1155
    lookupWithHelpers: function(name, isScoped) {
 
1156
      if(name) {
 
1157
        var topStack = this.nextStack();
 
1158
 
 
1159
        this.usingKnownHelper = false;
 
1160
 
 
1161
        var toPush;
 
1162
        if (!isScoped && this.options.knownHelpers[name]) {
 
1163
          toPush = topStack + " = " + this.nameLookup('helpers', name, 'helper');
 
1164
          this.usingKnownHelper = true;
 
1165
        } else if (isScoped || this.options.knownHelpersOnly) {
 
1166
          toPush = topStack + " = " + this.nameLookup('depth' + this.lastContext, name, 'context');
 
1167
        } else {
 
1168
          this.register('foundHelper', this.nameLookup('helpers', name, 'helper'));
 
1169
          toPush = topStack + " = foundHelper || " + this.nameLookup('depth' + this.lastContext, name, 'context');
 
1170
        }
 
1171
 
 
1172
        toPush += ';';
 
1173
        this.source.push(toPush);
 
1174
      } else {
 
1175
        this.pushStack('depth' + this.lastContext);
 
1176
      }
 
1177
    },
 
1178
 
 
1179
    lookup: function(name) {
 
1180
      var topStack = this.topStack();
 
1181
      this.source.push(topStack + " = (" + topStack + " === null || " + topStack + " === undefined || " + topStack + " === false ? " +
 
1182
         topStack + " : " + this.nameLookup(topStack, name, 'context') + ");");
 
1183
    },
 
1184
 
 
1185
    pushStringParam: function(string) {
 
1186
      this.pushStack('depth' + this.lastContext);
 
1187
      this.pushString(string);
 
1188
    },
 
1189
 
 
1190
    pushString: function(string) {
 
1191
      this.pushStack(this.quotedString(string));
 
1192
    },
 
1193
 
 
1194
    push: function(name) {
 
1195
      this.pushStack(name);
 
1196
    },
 
1197
 
 
1198
    invokeMustache: function(paramSize, original, hasHash) {
 
1199
      this.populateParams(paramSize, this.quotedString(original), "{}", null, hasHash, function(nextStack, helperMissingString, id) {
 
1200
        if (!this.usingKnownHelper) {
 
1201
          this.context.aliases.helperMissing = 'helpers.helperMissing';
 
1202
          this.context.aliases.undef = 'void 0';
 
1203
          this.source.push("else if(" + id + "=== undef) { " + nextStack + " = helperMissing.call(" + helperMissingString + "); }");
 
1204
          if (nextStack !== id) {
 
1205
            this.source.push("else { " + nextStack + " = " + id + "; }");
 
1206
          }
 
1207
        }
 
1208
      });
 
1209
    },
 
1210
 
 
1211
    invokeProgram: function(guid, paramSize, hasHash) {
 
1212
      var inverse = this.programExpression(this.inverse);
 
1213
      var mainProgram = this.programExpression(guid);
 
1214
 
 
1215
      this.populateParams(paramSize, null, mainProgram, inverse, hasHash, function(nextStack, helperMissingString, id) {
 
1216
        if (!this.usingKnownHelper) {
 
1217
          this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
 
1218
          this.source.push("else { " + nextStack + " = blockHelperMissing.call(" + helperMissingString + "); }");
 
1219
        }
 
1220
      });
 
1221
    },
 
1222
 
 
1223
    populateParams: function(paramSize, helperId, program, inverse, hasHash, fn) {
 
1224
      var needsRegister = hasHash || this.options.stringParams || inverse || this.options.data;
 
1225
      var id = this.popStack(), nextStack;
 
1226
      var params = [], param, stringParam, stringOptions;
 
1227
 
 
1228
      if (needsRegister) {
 
1229
        this.register('tmp1', program);
 
1230
        stringOptions = 'tmp1';
 
1231
      } else {
 
1232
        stringOptions = '{ hash: {} }';
 
1233
      }
 
1234
 
 
1235
      if (needsRegister) {
 
1236
        var hash = (hasHash ? this.popStack() : '{}');
 
1237
        this.source.push('tmp1.hash = ' + hash + ';');
 
1238
      }
 
1239
 
 
1240
      if(this.options.stringParams) {
 
1241
        this.source.push('tmp1.contexts = [];');
 
1242
      }
 
1243
 
 
1244
      for(var i=0; i<paramSize; i++) {
 
1245
        param = this.popStack();
 
1246
        params.push(param);
 
1247
 
 
1248
        if(this.options.stringParams) {
 
1249
          this.source.push('tmp1.contexts.push(' + this.popStack() + ');');
 
1250
        }
 
1251
      }
 
1252
 
 
1253
      if(inverse) {
 
1254
        this.source.push('tmp1.fn = tmp1;');
 
1255
        this.source.push('tmp1.inverse = ' + inverse + ';');
 
1256
      }
 
1257
 
 
1258
      if(this.options.data) {
 
1259
        this.source.push('tmp1.data = data;');
 
1260
      }
 
1261
 
 
1262
      params.push(stringOptions);
 
1263
 
 
1264
      this.populateCall(params, id, helperId || id, fn, program !== '{}');
 
1265
    },
 
1266
 
 
1267
    populateCall: function(params, id, helperId, fn, program) {
 
1268
      var paramString = ["depth0"].concat(params).join(", ");
 
1269
      var helperMissingString = ["depth0"].concat(helperId).concat(params).join(", ");
 
1270
 
 
1271
      var nextStack = this.nextStack();
 
1272
 
 
1273
      if (this.usingKnownHelper) {
 
1274
        this.source.push(nextStack + " = " + id + ".call(" + paramString + ");");
 
1275
      } else {
 
1276
        this.context.aliases.functionType = '"function"';
 
1277
        var condition = program ? "foundHelper && " : "";
 
1278
        this.source.push("if(" + condition + "typeof " + id + " === functionType) { " + nextStack + " = " + id + ".call(" + paramString + "); }");
 
1279
      }
 
1280
      fn.call(this, nextStack, helperMissingString, id);
 
1281
      this.usingKnownHelper = false;
 
1282
    },
 
1283
 
 
1284
    invokePartial: function(context) {
 
1285
      var params = [this.nameLookup('partials', context, 'partial'), "'" + context + "'", this.popStack(), "helpers", "partials"];
 
1286
 
 
1287
      if (this.options.data) {
 
1288
        params.push("data");
 
1289
      }
 
1290
 
 
1291
      this.pushStack("self.invokePartial(" + params.join(", ") + ");");
 
1292
    },
 
1293
 
 
1294
    assignToHash: function(key) {
 
1295
      var value = this.popStack();
 
1296
      var hash = this.topStack();
 
1297
 
 
1298
      this.source.push(hash + "['" + key + "'] = " + value + ";");
 
1299
    },
 
1300
 
 
1301
    // HELPERS
 
1302
 
 
1303
    compiler: JavaScriptCompiler,
 
1304
 
 
1305
    compileChildren: function(environment, options) {
 
1306
      var children = environment.children, child, compiler;
 
1307
 
 
1308
      for(var i=0, l=children.length; i<l; i++) {
 
1309
        child = children[i];
 
1310
        compiler = new this.compiler();
 
1311
 
 
1312
        this.context.programs.push('');     // Placeholder to prevent name conflicts for nested children
 
1313
        var index = this.context.programs.length;
 
1314
        child.index = index;
 
1315
        child.name = 'program' + index;
 
1316
        this.context.programs[index] = compiler.compile(child, options, this.context);
 
1317
      }
 
1318
    },
 
1319
 
 
1320
    programExpression: function(guid) {
 
1321
      if(guid == null) { return "self.noop"; }
 
1322
 
 
1323
      var child = this.environment.children[guid],
 
1324
          depths = child.depths.list, depth;
 
1325
 
 
1326
      var programParams = [child.index, child.name, "data"];
 
1327
 
 
1328
      for(var i=0, l = depths.length; i<l; i++) {
 
1329
        depth = depths[i];
 
1330
 
 
1331
        if(depth === 1) { programParams.push("depth0"); }
 
1332
        else { programParams.push("depth" + (depth - 1)); }
 
1333
      }
 
1334
 
 
1335
      if(depths.length === 0) {
 
1336
        return "self.program(" + programParams.join(", ") + ")";
 
1337
      } else {
 
1338
        programParams.shift();
 
1339
        return "self.programWithDepth(" + programParams.join(", ") + ")";
 
1340
      }
 
1341
    },
 
1342
 
 
1343
    register: function(name, val) {
 
1344
      this.useRegister(name);
 
1345
      this.source.push(name + " = " + val + ";");
 
1346
    },
 
1347
 
 
1348
    useRegister: function(name) {
 
1349
      if(!this.context.registers[name]) {
 
1350
        this.context.registers[name] = true;
 
1351
        this.context.registers.list.push(name);
 
1352
      }
 
1353
    },
 
1354
 
 
1355
    pushStack: function(item) {
 
1356
      this.source.push(this.nextStack() + " = " + item + ";");
 
1357
      return "stack" + this.stackSlot;
 
1358
    },
 
1359
 
 
1360
    nextStack: function() {
 
1361
      this.stackSlot++;
 
1362
      if(this.stackSlot > this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); }
 
1363
      return "stack" + this.stackSlot;
 
1364
    },
 
1365
 
 
1366
    popStack: function() {
 
1367
      return "stack" + this.stackSlot--;
 
1368
    },
 
1369
 
 
1370
    topStack: function() {
 
1371
      return "stack" + this.stackSlot;
 
1372
    },
 
1373
 
 
1374
    quotedString: function(str) {
 
1375
      return '"' + str
 
1376
        .replace(/\\/g, '\\\\')
 
1377
        .replace(/"/g, '\\"')
 
1378
        .replace(/\n/g, '\\n')
 
1379
        .replace(/\r/g, '\\r') + '"';
 
1380
    }
 
1381
  };
 
1382
 
 
1383
  var reservedWords = (
 
1384
    "break else new var" +
 
1385
    " case finally return void" +
 
1386
    " catch for switch while" +
 
1387
    " continue function this with" +
 
1388
    " default if throw" +
 
1389
    " delete in try" +
 
1390
    " do instanceof typeof" +
 
1391
    " abstract enum int short" +
 
1392
    " boolean export interface static" +
 
1393
    " byte extends long super" +
 
1394
    " char final native synchronized" +
 
1395
    " class float package throws" +
 
1396
    " const goto private transient" +
 
1397
    " debugger implements protected volatile" +
 
1398
    " double import public let yield"
 
1399
  ).split(" ");
 
1400
 
 
1401
  var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
 
1402
 
 
1403
  for(var i=0, l=reservedWords.length; i<l; i++) {
 
1404
    compilerWords[reservedWords[i]] = true;
 
1405
  }
 
1406
 
 
1407
  JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
 
1408
    if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) {
 
1409
      return true;
 
1410
    }
 
1411
    return false;
 
1412
  };
 
1413
 
 
1414
})(Handlebars.Compiler, Handlebars.JavaScriptCompiler);
 
1415
 
 
1416
Handlebars.precompile = function(string, options) {
 
1417
  options = options || {};
 
1418
 
 
1419
  var ast = Handlebars.parse(string);
 
1420
  var environment = new Handlebars.Compiler().compile(ast, options);
 
1421
  return new Handlebars.JavaScriptCompiler().compile(environment, options);
 
1422
};
 
1423
 
 
1424
Handlebars.compile = function(string, options) {
 
1425
  options = options || {};
 
1426
 
 
1427
  var compiled;
 
1428
  function compile() {
 
1429
    var ast = Handlebars.parse(string);
 
1430
    var environment = new Handlebars.Compiler().compile(ast, options);
 
1431
    var templateSpec = new Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
 
1432
    return Handlebars.template(templateSpec);
 
1433
  }
 
1434
 
 
1435
  // Template is only compiled on first use and cached after that point.
 
1436
  return function(context, options) {
 
1437
    if (!compiled) {
 
1438
      compiled = compile();
 
1439
    }
 
1440
    return compiled.call(this, context, options);
 
1441
  };
 
1442
};
 
1443
 
 
1444
// END(BROWSER)
 
1445
// This file contains YUI-specific wrapper code and overrides for the
 
1446
// handlebars-compiler module.
 
1447
 
 
1448
/**
 
1449
Handlebars parser and compiler. Use this module when you need to compile
 
1450
Handlebars templates.
 
1451
 
 
1452
@module handlebars
 
1453
@submodule handlebars-compiler
 
1454
*/
 
1455
 
 
1456
var levels = ['debug', 'info', 'warn', 'error'];
 
1457
 
 
1458
/**
 
1459
Logs a debugging message. Note that messages will only be logged when the
 
1460
handlebars module is loaded in "debug" mode.
 
1461
 
 
1462
@method log
 
1463
@param {String} level Log level for this message. Supported levels are "debug",
 
1464
    "info", "warn", and "error".
 
1465
@param {String} message Message to log.
 
1466
@for Handlebars
 
1467
*/
 
1468
Handlebars.logger.log = function (level, message) {
 
1469
    Y.log(message, levels[level] || 'error', 'Handlebars');
 
1470
};
 
1471
 
 
1472
/**
 
1473
Compiles and renders a Handlebars template string.
 
1474
 
 
1475
@example
 
1476
 
 
1477
    Y.Handlebars.render('The pie of the day is {{pie}}!', {
 
1478
        pie: 'Maple Custard'
 
1479
    });
 
1480
    // => "The pie of the day is Maple Custard!"
 
1481
 
 
1482
@method render
 
1483
@param {String} string Handlebars template string to render.
 
1484
@param {Object} context Context object to pass to the template.
 
1485
@param {Object} [options] Compile/render options.
 
1486
    @param {Object} [options.helpers] Helper functions.
 
1487
    @param {Object} [options.partials] Partials.
 
1488
    @param {Object} [options.data] Data.
 
1489
@return {String} Rendered template string.
 
1490
*/
 
1491
Handlebars.render = function (string, context, options) {
 
1492
    return Handlebars.compile(string)(context, options);
 
1493
};
 
1494
 
 
1495
// The rest of this file is just API docs for methods defined in Handlebars
 
1496
// itself.
 
1497
 
 
1498
/**
 
1499
Compiles a Handlebars template string into a function. To render the template,
 
1500
call the function and pass in a context object.
 
1501
 
 
1502
@example
 
1503
 
 
1504
    var template = Y.Handlebars.compile('The pie of the day is {{pie}}!.');
 
1505
    template({pie: 'Pecan'});
 
1506
    // => "The pie of the day is Pecan!"
 
1507
 
 
1508
@method compile
 
1509
@param {String} string Handlebars template string to compile.
 
1510
@param {Object} [options] Compiler options.
 
1511
@return {Function} Compiled template function.
 
1512
*/
 
1513
 
 
1514
/**
 
1515
Precompiles a Handlebars template string into a string of JavaScript code. This
 
1516
can be used to precompile a template at build time or on the server, and the
 
1517
resulting template can then be rendered at runtime or on the client without
 
1518
needing to go through a compile step.
 
1519
 
 
1520
To render a precompiled template, evaluate the code and then pass the resulting
 
1521
function to `Y.Handlebars.template()` to get back an executable template
 
1522
function.
 
1523
 
 
1524
@method precompile
 
1525
@param {String} string Handlebars template string to compile.
 
1526
@param {Object} [options] Compiler options.
 
1527
@return {String} Precompiled template code.
 
1528
*/
 
1529
 
 
1530
 
 
1531
}, '3.5.1' ,{requires:['handlebars-base']});