Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
YUI.add('handlebars-compiler', function (Y, NAME) {
2
 
3
/*!
4
Handlebars.js - Copyright (C) 2011 Yehuda Katz
5
https://raw.github.com/wycats/handlebars.js/master/LICENSE
6
*/
7
// This file contains code that will be inserted at the beginning of the
8
// handlebars-compiler module.
9
 
10
// This is necessary because the Y.Handlebars object is created in the
11
// handlebars-base module, but the native Handlebars code expects to use a local
12
// Handlebars reference.
13
var Handlebars = Y.Handlebars;
14
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
15
Handlebars.Helpers = {};
16
(function (exports, Exception) {
17
"use strict";
18
function stripFlags(open, close) {
19
  return {
20
    left: open.charAt(2) === '~',
21
    right: close.charAt(close.length-3) === '~'
22
  };
23
}
24
 
25
exports.stripFlags = stripFlags;
26
function prepareBlock(mustache, program, inverseAndProgram, close, inverted, locInfo) {
27
  /*jshint -W040 */
28
  if (mustache.sexpr.id.original !== close.path.original) {
29
    throw new Exception(mustache.sexpr.id.original + ' doesn\'t match ' + close.path.original, mustache);
30
  }
31
 
32
  var inverse = inverseAndProgram && inverseAndProgram.program;
33
 
34
  var strip = {
35
    left: mustache.strip.left,
36
    right: close.strip.right,
37
 
38
    // Determine the standalone candiacy. Basically flag our content as being possibly standalone
39
    // so our parent can determine if we actually are standalone
40
    openStandalone: isNextWhitespace(program.statements),
41
    closeStandalone: isPrevWhitespace((inverse || program).statements)
42
  };
43
 
44
  if (mustache.strip.right) {
45
    omitRight(program.statements, null, true);
46
  }
47
 
48
  if (inverse) {
49
    var inverseStrip = inverseAndProgram.strip;
50
 
51
    if (inverseStrip.left) {
52
      omitLeft(program.statements, null, true);
53
    }
54
    if (inverseStrip.right) {
55
      omitRight(inverse.statements, null, true);
56
    }
57
    if (close.strip.left) {
58
      omitLeft(inverse.statements, null, true);
59
    }
60
 
61
    // Find standalone else statments
62
    if (isPrevWhitespace(program.statements)
63
        && isNextWhitespace(inverse.statements)) {
64
 
65
      omitLeft(program.statements);
66
      omitRight(inverse.statements);
67
    }
68
  } else {
69
    if (close.strip.left) {
70
      omitLeft(program.statements, null, true);
71
    }
72
  }
73
 
74
  if (inverted) {
75
    return new this.BlockNode(mustache, inverse, program, strip, locInfo);
76
  } else {
77
    return new this.BlockNode(mustache, program, inverse, strip, locInfo);
78
  }
79
}
80
 
81
exports.prepareBlock = prepareBlock;
82
function prepareProgram(statements, isRoot) {
83
  for (var i = 0, l = statements.length; i < l; i++) {
84
    var current = statements[i],
85
        strip = current.strip;
86
 
87
    if (!strip) {
88
      continue;
89
    }
90
 
91
    var _isPrevWhitespace = isPrevWhitespace(statements, i, isRoot, current.type === 'partial'),
92
        _isNextWhitespace = isNextWhitespace(statements, i, isRoot),
93
 
94
        openStandalone = strip.openStandalone && _isPrevWhitespace,
95
        closeStandalone = strip.closeStandalone && _isNextWhitespace,
96
        inlineStandalone = strip.inlineStandalone && _isPrevWhitespace && _isNextWhitespace;
97
 
98
    if (strip.right) {
99
      omitRight(statements, i, true);
100
    }
101
    if (strip.left) {
102
      omitLeft(statements, i, true);
103
    }
104
 
105
    if (inlineStandalone) {
106
      omitRight(statements, i);
107
 
108
      if (omitLeft(statements, i)) {
109
        // If we are on a standalone node, save the indent info for partials
110
        if (current.type === 'partial') {
111
          current.indent = (/([ \t]+$)/).exec(statements[i-1].original) ? RegExp.$1 : '';
112
        }
113
      }
114
    }
115
    if (openStandalone) {
116
      omitRight((current.program || current.inverse).statements);
117
 
118
      // Strip out the previous content node if it's whitespace only
119
      omitLeft(statements, i);
120
    }
121
    if (closeStandalone) {
122
      // Always strip the next node
123
      omitRight(statements, i);
124
 
125
      omitLeft((current.inverse || current.program).statements);
126
    }
127
  }
128
 
129
  return statements;
130
}
131
 
132
exports.prepareProgram = prepareProgram;function isPrevWhitespace(statements, i, isRoot) {
133
  if (i === undefined) {
134
    i = statements.length;
135
  }
136
 
137
  // Nodes that end with newlines are considered whitespace (but are special
138
  // cased for strip operations)
139
  var prev = statements[i-1],
140
      sibling = statements[i-2];
141
  if (!prev) {
142
    return isRoot;
143
  }
144
 
145
  if (prev.type === 'content') {
146
    return (sibling || !isRoot ? (/\r?\n\s*?$/) : (/(^|\r?\n)\s*?$/)).test(prev.original);
147
  }
148
}
149
function isNextWhitespace(statements, i, isRoot) {
150
  if (i === undefined) {
151
    i = -1;
152
  }
153
 
154
  var next = statements[i+1],
155
      sibling = statements[i+2];
156
  if (!next) {
157
    return isRoot;
158
  }
159
 
160
  if (next.type === 'content') {
161
    return (sibling || !isRoot ? (/^\s*?\r?\n/) : (/^\s*?(\r?\n|$)/)).test(next.original);
162
  }
163
}
164
 
165
// Marks the node to the right of the position as omitted.
166
// I.e. {{foo}}' ' will mark the ' ' node as omitted.
167
//
168
// If i is undefined, then the first child will be marked as such.
169
//
170
// If mulitple is truthy then all whitespace will be stripped out until non-whitespace
171
// content is met.
172
function omitRight(statements, i, multiple) {
173
  var current = statements[i == null ? 0 : i + 1];
174
  if (!current || current.type !== 'content' || (!multiple && current.rightStripped)) {
175
    return;
176
  }
177
 
178
  var original = current.string;
179
  current.string = current.string.replace(multiple ? (/^\s+/) : (/^[ \t]*\r?\n?/), '');
180
  current.rightStripped = current.string !== original;
181
}
182
 
183
// Marks the node to the left of the position as omitted.
184
// I.e. ' '{{foo}} will mark the ' ' node as omitted.
185
//
186
// If i is undefined then the last child will be marked as such.
187
//
188
// If mulitple is truthy then all whitespace will be stripped out until non-whitespace
189
// content is met.
190
function omitLeft(statements, i, multiple) {
191
  var current = statements[i == null ? statements.length - 1 : i - 1];
192
  if (!current || current.type !== 'content' || (!multiple && current.leftStripped)) {
193
    return;
194
  }
195
 
196
  // We omit the last node if it's whitespace only and not preceeded by a non-content node.
197
  var original = current.string;
198
  current.string = current.string.replace(multiple ? (/\s+$/) : (/[ \t]+$/), '');
199
  current.leftStripped = current.string !== original;
200
  return current.leftStripped;
201
}
202
}(Handlebars.Helpers, Handlebars.Exception));
203
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
204
Handlebars.Parser = {};
205
(function (exports) {
206
"use strict";
207
/* jshint ignore:start */
208
/* istanbul ignore next */
209
/* Jison generated parser */
210
var handlebars = (function(){
211
var parser = {trace: function trace() { },
212
yy: {},
213
symbols_: {"error":2,"root":3,"program":4,"EOF":5,"program_repetition0":6,"statement":7,"mustache":8,"block":9,"rawBlock":10,"partial":11,"CONTENT":12,"COMMENT":13,"openRawBlock":14,"END_RAW_BLOCK":15,"OPEN_RAW_BLOCK":16,"sexpr":17,"CLOSE_RAW_BLOCK":18,"openBlock":19,"block_option0":20,"closeBlock":21,"openInverse":22,"block_option1":23,"OPEN_BLOCK":24,"CLOSE":25,"OPEN_INVERSE":26,"inverseAndProgram":27,"INVERSE":28,"OPEN_ENDBLOCK":29,"path":30,"OPEN":31,"OPEN_UNESCAPED":32,"CLOSE_UNESCAPED":33,"OPEN_PARTIAL":34,"partialName":35,"param":36,"partial_option0":37,"partial_option1":38,"sexpr_repetition0":39,"sexpr_option0":40,"dataName":41,"STRING":42,"NUMBER":43,"BOOLEAN":44,"OPEN_SEXPR":45,"CLOSE_SEXPR":46,"hash":47,"hash_repetition_plus0":48,"hashSegment":49,"ID":50,"EQUALS":51,"DATA":52,"pathSegments":53,"SEP":54,"$accept":0,"$end":1},
214
terminals_: {2:"error",5:"EOF",12:"CONTENT",13:"COMMENT",15:"END_RAW_BLOCK",16:"OPEN_RAW_BLOCK",18:"CLOSE_RAW_BLOCK",24:"OPEN_BLOCK",25:"CLOSE",26:"OPEN_INVERSE",28:"INVERSE",29:"OPEN_ENDBLOCK",31:"OPEN",32:"OPEN_UNESCAPED",33:"CLOSE_UNESCAPED",34:"OPEN_PARTIAL",42:"STRING",43:"NUMBER",44:"BOOLEAN",45:"OPEN_SEXPR",46:"CLOSE_SEXPR",50:"ID",51:"EQUALS",52:"DATA",54:"SEP"},
215
productions_: [0,[3,2],[4,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[10,3],[14,3],[9,4],[9,4],[19,3],[22,3],[27,2],[21,3],[8,3],[8,3],[11,5],[11,4],[17,3],[17,1],[36,1],[36,1],[36,1],[36,1],[36,1],[36,3],[47,1],[49,3],[35,1],[35,1],[35,1],[41,2],[30,1],[53,3],[53,1],[6,0],[6,2],[20,0],[20,1],[23,0],[23,1],[37,0],[37,1],[38,0],[38,1],[39,0],[39,2],[40,0],[40,1],[48,1],[48,2]],
216
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$,_$) {
217
 
218
var $0 = $.length - 1;
219
switch (yystate) {
220
case 1: yy.prepareProgram($[$0-1].statements, true); return $[$0-1];
221
break;
222
case 2:this.$ = new yy.ProgramNode(yy.prepareProgram($[$0]), {}, this._$);
223
break;
224
case 3:this.$ = $[$0];
225
break;
226
case 4:this.$ = $[$0];
227
break;
228
case 5:this.$ = $[$0];
229
break;
230
case 6:this.$ = $[$0];
231
break;
232
case 7:this.$ = new yy.ContentNode($[$0], this._$);
233
break;
234
case 8:this.$ = new yy.CommentNode($[$0], this._$);
235
break;
236
case 9:this.$ = new yy.RawBlockNode($[$0-2], $[$0-1], $[$0], this._$);
237
break;
238
case 10:this.$ = new yy.MustacheNode($[$0-1], null, '', '', this._$);
239
break;
240
case 11:this.$ = yy.prepareBlock($[$0-3], $[$0-2], $[$0-1], $[$0], false, this._$);
241
break;
242
case 12:this.$ = yy.prepareBlock($[$0-3], $[$0-2], $[$0-1], $[$0], true, this._$);
243
break;
244
case 13:this.$ = new yy.MustacheNode($[$0-1], null, $[$0-2], yy.stripFlags($[$0-2], $[$0]), this._$);
245
break;
246
case 14:this.$ = new yy.MustacheNode($[$0-1], null, $[$0-2], yy.stripFlags($[$0-2], $[$0]), this._$);
247
break;
248
case 15:this.$ = { strip: yy.stripFlags($[$0-1], $[$0-1]), program: $[$0] };
249
break;
250
case 16:this.$ = {path: $[$0-1], strip: yy.stripFlags($[$0-2], $[$0])};
251
break;
252
case 17:this.$ = new yy.MustacheNode($[$0-1], null, $[$0-2], yy.stripFlags($[$0-2], $[$0]), this._$);
253
break;
254
case 18:this.$ = new yy.MustacheNode($[$0-1], null, $[$0-2], yy.stripFlags($[$0-2], $[$0]), this._$);
255
break;
256
case 19:this.$ = new yy.PartialNode($[$0-3], $[$0-2], $[$0-1], yy.stripFlags($[$0-4], $[$0]), this._$);
257
break;
258
case 20:this.$ = new yy.PartialNode($[$0-2], undefined, $[$0-1], yy.stripFlags($[$0-3], $[$0]), this._$);
259
break;
260
case 21:this.$ = new yy.SexprNode([$[$0-2]].concat($[$0-1]), $[$0], this._$);
261
break;
262
case 22:this.$ = new yy.SexprNode([$[$0]], null, this._$);
263
break;
264
case 23:this.$ = $[$0];
265
break;
266
case 24:this.$ = new yy.StringNode($[$0], this._$);
267
break;
268
case 25:this.$ = new yy.NumberNode($[$0], this._$);
269
break;
270
case 26:this.$ = new yy.BooleanNode($[$0], this._$);
271
break;
272
case 27:this.$ = $[$0];
273
break;
274
case 28:$[$0-1].isHelper = true; this.$ = $[$0-1];
275
break;
276
case 29:this.$ = new yy.HashNode($[$0], this._$);
277
break;
278
case 30:this.$ = [$[$0-2], $[$0]];
279
break;
280
case 31:this.$ = new yy.PartialNameNode($[$0], this._$);
281
break;
282
case 32:this.$ = new yy.PartialNameNode(new yy.StringNode($[$0], this._$), this._$);
283
break;
284
case 33:this.$ = new yy.PartialNameNode(new yy.NumberNode($[$0], this._$));
285
break;
286
case 34:this.$ = new yy.DataNode($[$0], this._$);
287
break;
288
case 35:this.$ = new yy.IdNode($[$0], this._$);
289
break;
290
case 36: $[$0-2].push({part: $[$0], separator: $[$0-1]}); this.$ = $[$0-2];
291
break;
292
case 37:this.$ = [{part: $[$0]}];
293
break;
294
case 38:this.$ = [];
295
break;
296
case 39:$[$0-1].push($[$0]);
297
break;
298
case 48:this.$ = [];
299
break;
300
case 49:$[$0-1].push($[$0]);
301
break;
302
case 52:this.$ = [$[$0]];
303
break;
304
case 53:$[$0-1].push($[$0]);
305
break;
306
}
307
},
308
table: [{3:1,4:2,5:[2,38],6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],31:[2,38],32:[2,38],34:[2,38]},{1:[3]},{5:[1,4]},{5:[2,2],7:5,8:6,9:7,10:8,11:9,12:[1,10],13:[1,11],14:16,16:[1,20],19:14,22:15,24:[1,18],26:[1,19],28:[2,2],29:[2,2],31:[1,12],32:[1,13],34:[1,17]},{1:[2,1]},{5:[2,39],12:[2,39],13:[2,39],16:[2,39],24:[2,39],26:[2,39],28:[2,39],29:[2,39],31:[2,39],32:[2,39],34:[2,39]},{5:[2,3],12:[2,3],13:[2,3],16:[2,3],24:[2,3],26:[2,3],28:[2,3],29:[2,3],31:[2,3],32:[2,3],34:[2,3]},{5:[2,4],12:[2,4],13:[2,4],16:[2,4],24:[2,4],26:[2,4],28:[2,4],29:[2,4],31:[2,4],32:[2,4],34:[2,4]},{5:[2,5],12:[2,5],13:[2,5],16:[2,5],24:[2,5],26:[2,5],28:[2,5],29:[2,5],31:[2,5],32:[2,5],34:[2,5]},{5:[2,6],12:[2,6],13:[2,6],16:[2,6],24:[2,6],26:[2,6],28:[2,6],29:[2,6],31:[2,6],32:[2,6],34:[2,6]},{5:[2,7],12:[2,7],13:[2,7],16:[2,7],24:[2,7],26:[2,7],28:[2,7],29:[2,7],31:[2,7],32:[2,7],34:[2,7]},{5:[2,8],12:[2,8],13:[2,8],16:[2,8],24:[2,8],26:[2,8],28:[2,8],29:[2,8],31:[2,8],32:[2,8],34:[2,8]},{17:21,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:27,30:22,41:23,50:[1,26],52:[1,25],53:24},{4:28,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],28:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{4:29,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],28:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{12:[1,30]},{30:32,35:31,42:[1,33],43:[1,34],50:[1,26],53:24},{17:35,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:36,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:37,30:22,41:23,50:[1,26],52:[1,25],53:24},{25:[1,38]},{18:[2,48],25:[2,48],33:[2,48],39:39,42:[2,48],43:[2,48],44:[2,48],45:[2,48],46:[2,48],50:[2,48],52:[2,48]},{18:[2,22],25:[2,22],33:[2,22],46:[2,22]},{18:[2,35],25:[2,35],33:[2,35],42:[2,35],43:[2,35],44:[2,35],45:[2,35],46:[2,35],50:[2,35],52:[2,35],54:[1,40]},{30:41,50:[1,26],53:24},{18:[2,37],25:[2,37],33:[2,37],42:[2,37],43:[2,37],44:[2,37],45:[2,37],46:[2,37],50:[2,37],52:[2,37],54:[2,37]},{33:[1,42]},{20:43,27:44,28:[1,45],29:[2,40]},{23:46,27:47,28:[1,45],29:[2,42]},{15:[1,48]},{25:[2,46],30:51,36:49,38:50,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],47:57,48:58,49:60,50:[1,59],52:[1,25],53:24},{25:[2,31],42:[2,31],43:[2,31],44:[2,31],45:[2,31],50:[2,31],52:[2,31]},{25:[2,32],42:[2,32],43:[2,32],44:[2,32],45:[2,32],50:[2,32],52:[2,32]},{25:[2,33],42:[2,33],43:[2,33],44:[2,33],45:[2,33],50:[2,33],52:[2,33]},{25:[1,61]},{25:[1,62]},{18:[1,63]},{5:[2,17],12:[2,17],13:[2,17],16:[2,17],24:[2,17],26:[2,17],28:[2,17],29:[2,17],31:[2,17],32:[2,17],34:[2,17]},{18:[2,50],25:[2,50],30:51,33:[2,50],36:65,40:64,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],46:[2,50],47:66,48:58,49:60,50:[1,59],52:[1,25],53:24},{50:[1,67]},{18:[2,34],25:[2,34],33:[2,34],42:[2,34],43:[2,34],44:[2,34],45:[2,34],46:[2,34],50:[2,34],52:[2,34]},{5:[2,18],12:[2,18],13:[2,18],16:[2,18],24:[2,18],26:[2,18],28:[2,18],29:[2,18],31:[2,18],32:[2,18],34:[2,18]},{21:68,29:[1,69]},{29:[2,41]},{4:70,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{21:71,29:[1,69]},{29:[2,43]},{5:[2,9],12:[2,9],13:[2,9],16:[2,9],24:[2,9],26:[2,9],28:[2,9],29:[2,9],31:[2,9],32:[2,9],34:[2,9]},{25:[2,44],37:72,47:73,48:58,49:60,50:[1,74]},{25:[1,75]},{18:[2,23],25:[2,23],33:[2,23],42:[2,23],43:[2,23],44:[2,23],45:[2,23],46:[2,23],50:[2,23],52:[2,23]},{18:[2,24],25:[2,24],33:[2,24],42:[2,24],43:[2,24],44:[2,24],45:[2,24],46:[2,24],50:[2,24],52:[2,24]},{18:[2,25],25:[2,25],33:[2,25],42:[2,25],43:[2,25],44:[2,25],45:[2,25],46:[2,25],50:[2,25],52:[2,25]},{18:[2,26],25:[2,26],33:[2,26],42:[2,26],43:[2,26],44:[2,26],45:[2,26],46:[2,26],50:[2,26],52:[2,26]},{18:[2,27],25:[2,27],33:[2,27],42:[2,27],43:[2,27],44:[2,27],45:[2,27],46:[2,27],50:[2,27],52:[2,27]},{17:76,30:22,41:23,50:[1,26],52:[1,25],53:24},{25:[2,47]},{18:[2,29],25:[2,29],33:[2,29],46:[2,29],49:77,50:[1,74]},{18:[2,37],25:[2,37],33:[2,37],42:[2,37],43:[2,37],44:[2,37],45:[2,37],46:[2,37],50:[2,37],51:[1,78],52:[2,37],54:[2,37]},{18:[2,52],25:[2,52],33:[2,52],46:[2,52],50:[2,52]},{12:[2,13],13:[2,13],16:[2,13],24:[2,13],26:[2,13],28:[2,13],29:[2,13],31:[2,13],32:[2,13],34:[2,13]},{12:[2,14],13:[2,14],16:[2,14],24:[2,14],26:[2,14],28:[2,14],29:[2,14],31:[2,14],32:[2,14],34:[2,14]},{12:[2,10]},{18:[2,21],25:[2,21],33:[2,21],46:[2,21]},{18:[2,49],25:[2,49],33:[2,49],42:[2,49],43:[2,49],44:[2,49],45:[2,49],46:[2,49],50:[2,49],52:[2,49]},{18:[2,51],25:[2,51],33:[2,51],46:[2,51]},{18:[2,36],25:[2,36],33:[2,36],42:[2,36],43:[2,36],44:[2,36],45:[2,36],46:[2,36],50:[2,36],52:[2,36],54:[2,36]},{5:[2,11],12:[2,11],13:[2,11],16:[2,11],24:[2,11],26:[2,11],28:[2,11],29:[2,11],31:[2,11],32:[2,11],34:[2,11]},{30:79,50:[1,26],53:24},{29:[2,15]},{5:[2,12],12:[2,12],13:[2,12],16:[2,12],24:[2,12],26:[2,12],28:[2,12],29:[2,12],31:[2,12],32:[2,12],34:[2,12]},{25:[1,80]},{25:[2,45]},{51:[1,78]},{5:[2,20],12:[2,20],13:[2,20],16:[2,20],24:[2,20],26:[2,20],28:[2,20],29:[2,20],31:[2,20],32:[2,20],34:[2,20]},{46:[1,81]},{18:[2,53],25:[2,53],33:[2,53],46:[2,53],50:[2,53]},{30:51,36:82,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],50:[1,26],52:[1,25],53:24},{25:[1,83]},{5:[2,19],12:[2,19],13:[2,19],16:[2,19],24:[2,19],26:[2,19],28:[2,19],29:[2,19],31:[2,19],32:[2,19],34:[2,19]},{18:[2,28],25:[2,28],33:[2,28],42:[2,28],43:[2,28],44:[2,28],45:[2,28],46:[2,28],50:[2,28],52:[2,28]},{18:[2,30],25:[2,30],33:[2,30],46:[2,30],50:[2,30]},{5:[2,16],12:[2,16],13:[2,16],16:[2,16],24:[2,16],26:[2,16],28:[2,16],29:[2,16],31:[2,16],32:[2,16],34:[2,16]}],
309
defaultActions: {4:[2,1],44:[2,41],47:[2,43],57:[2,47],63:[2,10],70:[2,15],73:[2,45]},
310
parseError: function parseError(str, hash) {
311
    throw new Error(str);
312
},
313
parse: function parse(input) {
314
    var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
315
    this.lexer.setInput(input);
316
    this.lexer.yy = this.yy;
317
    this.yy.lexer = this.lexer;
318
    this.yy.parser = this;
319
    if (typeof this.lexer.yylloc == "undefined")
320
        this.lexer.yylloc = {};
321
    var yyloc = this.lexer.yylloc;
322
    lstack.push(yyloc);
323
    var ranges = this.lexer.options && this.lexer.options.ranges;
324
    if (typeof this.yy.parseError === "function")
325
        this.parseError = this.yy.parseError;
326
    function popStack(n) {
327
        stack.length = stack.length - 2 * n;
328
        vstack.length = vstack.length - n;
329
        lstack.length = lstack.length - n;
330
    }
331
    function lex() {
332
        var token;
333
        token = self.lexer.lex() || 1;
334
        if (typeof token !== "number") {
335
            token = self.symbols_[token] || token;
336
        }
337
        return token;
338
    }
339
    var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
340
    while (true) {
341
        state = stack[stack.length - 1];
342
        if (this.defaultActions[state]) {
343
            action = this.defaultActions[state];
344
        } else {
345
            if (symbol === null || typeof symbol == "undefined") {
346
                symbol = lex();
347
            }
348
            action = table[state] && table[state][symbol];
349
        }
350
        if (typeof action === "undefined" || !action.length || !action[0]) {
351
            var errStr = "";
352
            if (!recovering) {
353
                expected = [];
354
                for (p in table[state])
355
                    if (this.terminals_[p] && p > 2) {
356
                        expected.push("'" + this.terminals_[p] + "'");
357
                    }
358
                if (this.lexer.showPosition) {
359
                    errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
360
                } else {
361
                    errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'");
362
                }
363
                this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
364
            }
365
        }
366
        if (action[0] instanceof Array && action.length > 1) {
367
            throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
368
        }
369
        switch (action[0]) {
370
        case 1:
371
            stack.push(symbol);
372
            vstack.push(this.lexer.yytext);
373
            lstack.push(this.lexer.yylloc);
374
            stack.push(action[1]);
375
            symbol = null;
376
            if (!preErrorSymbol) {
377
                yyleng = this.lexer.yyleng;
378
                yytext = this.lexer.yytext;
379
                yylineno = this.lexer.yylineno;
380
                yyloc = this.lexer.yylloc;
381
                if (recovering > 0)
382
                    recovering--;
383
            } else {
384
                symbol = preErrorSymbol;
385
                preErrorSymbol = null;
386
            }
387
            break;
388
        case 2:
389
            len = this.productions_[action[1]][1];
390
            yyval.$ = vstack[vstack.length - len];
391
            yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column};
392
            if (ranges) {
393
                yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
394
            }
395
            r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
396
            if (typeof r !== "undefined") {
397
                return r;
398
            }
399
            if (len) {
400
                stack = stack.slice(0, -1 * len * 2);
401
                vstack = vstack.slice(0, -1 * len);
402
                lstack = lstack.slice(0, -1 * len);
403
            }
404
            stack.push(this.productions_[action[1]][0]);
405
            vstack.push(yyval.$);
406
            lstack.push(yyval._$);
407
            newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
408
            stack.push(newState);
409
            break;
410
        case 3:
411
            return true;
412
        }
413
    }
414
    return true;
415
}
416
};
417
/* Jison generated lexer */
418
var lexer = (function(){
419
var lexer = ({EOF:1,
420
parseError:function parseError(str, hash) {
421
        if (this.yy.parser) {
422
            this.yy.parser.parseError(str, hash);
423
        } else {
424
            throw new Error(str);
425
        }
426
    },
427
setInput:function (input) {
428
        this._input = input;
429
        this._more = this._less = this.done = false;
430
        this.yylineno = this.yyleng = 0;
431
        this.yytext = this.matched = this.match = '';
432
        this.conditionStack = ['INITIAL'];
433
        this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
434
        if (this.options.ranges) this.yylloc.range = [0,0];
435
        this.offset = 0;
436
        return this;
437
    },
438
input:function () {
439
        var ch = this._input[0];
440
        this.yytext += ch;
441
        this.yyleng++;
442
        this.offset++;
443
        this.match += ch;
444
        this.matched += ch;
445
        var lines = ch.match(/(?:\r\n?|\n).*/g);
446
        if (lines) {
447
            this.yylineno++;
448
            this.yylloc.last_line++;
449
        } else {
450
            this.yylloc.last_column++;
451
        }
452
        if (this.options.ranges) this.yylloc.range[1]++;
453
 
454
        this._input = this._input.slice(1);
455
        return ch;
456
    },
457
unput:function (ch) {
458
        var len = ch.length;
459
        var lines = ch.split(/(?:\r\n?|\n)/g);
460
 
461
        this._input = ch + this._input;
462
        this.yytext = this.yytext.substr(0, this.yytext.length-len-1);
463
        //this.yyleng -= len;
464
        this.offset -= len;
465
        var oldLines = this.match.split(/(?:\r\n?|\n)/g);
466
        this.match = this.match.substr(0, this.match.length-1);
467
        this.matched = this.matched.substr(0, this.matched.length-1);
468
 
469
        if (lines.length-1) this.yylineno -= lines.length-1;
470
        var r = this.yylloc.range;
471
 
472
        this.yylloc = {first_line: this.yylloc.first_line,
473
          last_line: this.yylineno+1,
474
          first_column: this.yylloc.first_column,
475
          last_column: lines ?
476
              (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length:
477
              this.yylloc.first_column - len
478
          };
479
 
480
        if (this.options.ranges) {
481
            this.yylloc.range = [r[0], r[0] + this.yyleng - len];
482
        }
483
        return this;
484
    },
485
more:function () {
486
        this._more = true;
487
        return this;
488
    },
489
less:function (n) {
490
        this.unput(this.match.slice(n));
491
    },
492
pastInput:function () {
493
        var past = this.matched.substr(0, this.matched.length - this.match.length);
494
        return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
495
    },
496
upcomingInput:function () {
497
        var next = this.match;
498
        if (next.length < 20) {
499
            next += this._input.substr(0, 20-next.length);
500
        }
501
        return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
502
    },
503
showPosition:function () {
504
        var pre = this.pastInput();
505
        var c = new Array(pre.length + 1).join("-");
506
        return pre + this.upcomingInput() + "\n" + c+"^";
507
    },
508
next:function () {
509
        if (this.done) {
510
            return this.EOF;
511
        }
512
        if (!this._input) this.done = true;
513
 
514
        var token,
515
            match,
516
            tempMatch,
517
            index,
518
            col,
519
            lines;
520
        if (!this._more) {
521
            this.yytext = '';
522
            this.match = '';
523
        }
524
        var rules = this._currentRules();
525
        for (var i=0;i < rules.length; i++) {
526
            tempMatch = this._input.match(this.rules[rules[i]]);
527
            if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
528
                match = tempMatch;
529
                index = i;
530
                if (!this.options.flex) break;
531
            }
532
        }
533
        if (match) {
534
            lines = match[0].match(/(?:\r\n?|\n).*/g);
535
            if (lines) this.yylineno += lines.length;
536
            this.yylloc = {first_line: this.yylloc.last_line,
537
                           last_line: this.yylineno+1,
538
                           first_column: this.yylloc.last_column,
539
                           last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length};
540
            this.yytext += match[0];
541
            this.match += match[0];
542
            this.matches = match;
543
            this.yyleng = this.yytext.length;
544
            if (this.options.ranges) {
545
                this.yylloc.range = [this.offset, this.offset += this.yyleng];
546
            }
547
            this._more = false;
548
            this._input = this._input.slice(match[0].length);
549
            this.matched += match[0];
550
            token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
551
            if (this.done && this._input) this.done = false;
552
            if (token) return token;
553
            else return;
554
        }
555
        if (this._input === "") {
556
            return this.EOF;
557
        } else {
558
            return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
559
                    {text: "", token: null, line: this.yylineno});
560
        }
561
    },
562
lex:function lex() {
563
        var r = this.next();
564
        if (typeof r !== 'undefined') {
565
            return r;
566
        } else {
567
            return this.lex();
568
        }
569
    },
570
begin:function begin(condition) {
571
        this.conditionStack.push(condition);
572
    },
573
popState:function popState() {
574
        return this.conditionStack.pop();
575
    },
576
_currentRules:function _currentRules() {
577
        return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
578
    },
579
topState:function () {
580
        return this.conditionStack[this.conditionStack.length-2];
581
    },
582
pushState:function begin(condition) {
583
        this.begin(condition);
584
    }});
585
lexer.options = {};
586
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
587
 
588
 
589
function strip(start, end) {
590
  return yy_.yytext = yy_.yytext.substr(start, yy_.yyleng-end);
591
}
592
 
593
 
594
var YYSTATE=YY_START
595
switch($avoiding_name_collisions) {
596
case 0:
597
                                   if(yy_.yytext.slice(-2) === "\\\\") {
598
                                     strip(0,1);
599
                                     this.begin("mu");
600
                                   } else if(yy_.yytext.slice(-1) === "\\") {
601
                                     strip(0,1);
602
                                     this.begin("emu");
603
                                   } else {
604
                                     this.begin("mu");
605
                                   }
606
                                   if(yy_.yytext) return 12;
607
 
608
break;
609
case 1:return 12;
610
break;
611
case 2:
612
                                   this.popState();
613
                                   return 12;
614
 
615
break;
616
case 3:
617
                                  yy_.yytext = yy_.yytext.substr(5, yy_.yyleng-9);
618
                                  this.popState();
619
                                  return 15;
620
 
621
break;
622
case 4: return 12;
623
break;
624
case 5:strip(0,4); this.popState(); return 13;
625
break;
626
case 6:return 45;
627
break;
628
case 7:return 46;
629
break;
630
case 8: return 16;
631
break;
632
case 9:
633
                                  this.popState();
634
                                  this.begin('raw');
635
                                  return 18;
636
 
637
break;
638
case 10:return 34;
639
break;
640
case 11:return 24;
641
break;
642
case 12:return 29;
643
break;
644
case 13:this.popState(); return 28;
645
break;
646
case 14:this.popState(); return 28;
647
break;
648
case 15:return 26;
649
break;
650
case 16:return 26;
651
break;
652
case 17:return 32;
653
break;
654
case 18:return 31;
655
break;
656
case 19:this.popState(); this.begin('com');
657
break;
658
case 20:strip(3,5); this.popState(); return 13;
659
break;
660
case 21:return 31;
661
break;
662
case 22:return 51;
663
break;
664
case 23:return 50;
665
break;
666
case 24:return 50;
667
break;
668
case 25:return 54;
669
break;
670
case 26:// ignore whitespace
671
break;
672
case 27:this.popState(); return 33;
673
break;
674
case 28:this.popState(); return 25;
675
break;
676
case 29:yy_.yytext = strip(1,2).replace(/\\"/g,'"'); return 42;
677
break;
678
case 30:yy_.yytext = strip(1,2).replace(/\\'/g,"'"); return 42;
679
break;
680
case 31:return 52;
681
break;
682
case 32:return 44;
683
break;
684
case 33:return 44;
685
break;
686
case 34:return 43;
687
break;
688
case 35:return 50;
689
break;
690
case 36:yy_.yytext = strip(1,2); return 50;
691
break;
692
case 37:return 'INVALID';
693
break;
694
case 38:return 5;
695
break;
696
}
697
};
698
lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]*?(?=(\{\{\{\{\/)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
699
lexer.conditions = {"mu":{"rules":[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"com":{"rules":[5],"inclusive":false},"raw":{"rules":[3,4],"inclusive":false},"INITIAL":{"rules":[0,1,38],"inclusive":true}};
700
return lexer;})()
701
parser.lexer = lexer;
702
function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
703
return new Parser;
704
})();exports["default"] = handlebars;
705
/* jshint ignore:end */
706
}(Handlebars.Parser));
707
Handlebars.Parser = Handlebars.Parser['default'];
708
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
709
Handlebars.AST = {};
710
(function (exports, Exception) {
711
"use strict";
712
function LocationInfo(locInfo) {
713
  locInfo = locInfo || {};
714
  this.firstLine   = locInfo.first_line;
715
  this.firstColumn = locInfo.first_column;
716
  this.lastColumn  = locInfo.last_column;
717
  this.lastLine    = locInfo.last_line;
718
}
719
 
720
var AST = {
721
  ProgramNode: function(statements, strip, locInfo) {
722
    LocationInfo.call(this, locInfo);
723
    this.type = "program";
724
    this.statements = statements;
725
    this.strip = strip;
726
  },
727
 
728
  MustacheNode: function(rawParams, hash, open, strip, locInfo) {
729
    LocationInfo.call(this, locInfo);
730
    this.type = "mustache";
731
    this.strip = strip;
732
 
733
    // Open may be a string parsed from the parser or a passed boolean flag
734
    if (open != null && open.charAt) {
735
      // Must use charAt to support IE pre-10
736
      var escapeFlag = open.charAt(3) || open.charAt(2);
737
      this.escaped = escapeFlag !== '{' && escapeFlag !== '&';
738
    } else {
739
      this.escaped = !!open;
740
    }
741
 
742
    if (rawParams instanceof AST.SexprNode) {
743
      this.sexpr = rawParams;
744
    } else {
745
      // Support old AST API
746
      this.sexpr = new AST.SexprNode(rawParams, hash);
747
    }
748
 
749
    // Support old AST API that stored this info in MustacheNode
750
    this.id = this.sexpr.id;
751
    this.params = this.sexpr.params;
752
    this.hash = this.sexpr.hash;
753
    this.eligibleHelper = this.sexpr.eligibleHelper;
754
    this.isHelper = this.sexpr.isHelper;
755
  },
756
 
757
  SexprNode: function(rawParams, hash, locInfo) {
758
    LocationInfo.call(this, locInfo);
759
 
760
    this.type = "sexpr";
761
    this.hash = hash;
762
 
763
    var id = this.id = rawParams[0];
764
    var params = this.params = rawParams.slice(1);
765
 
766
    // a mustache is definitely a helper if:
767
    // * it is an eligible helper, and
768
    // * it has at least one parameter or hash segment
769
    this.isHelper = !!(params.length || hash);
770
 
771
    // a mustache is an eligible helper if:
772
    // * its id is simple (a single part, not `this` or `..`)
773
    this.eligibleHelper = this.isHelper || id.isSimple;
774
 
775
    // if a mustache is an eligible helper but not a definite
776
    // helper, it is ambiguous, and will be resolved in a later
777
    // pass or at runtime.
778
  },
779
 
780
  PartialNode: function(partialName, context, hash, strip, locInfo) {
781
    LocationInfo.call(this, locInfo);
782
    this.type         = "partial";
783
    this.partialName  = partialName;
784
    this.context      = context;
785
    this.hash = hash;
786
    this.strip = strip;
787
 
788
    this.strip.inlineStandalone = true;
789
  },
790
 
791
  BlockNode: function(mustache, program, inverse, strip, locInfo) {
792
    LocationInfo.call(this, locInfo);
793
 
794
    this.type = 'block';
795
    this.mustache = mustache;
796
    this.program  = program;
797
    this.inverse  = inverse;
798
    this.strip = strip;
799
 
800
    if (inverse && !program) {
801
      this.isInverse = true;
802
    }
803
  },
804
 
805
  RawBlockNode: function(mustache, content, close, locInfo) {
806
    LocationInfo.call(this, locInfo);
807
 
808
    if (mustache.sexpr.id.original !== close) {
809
      throw new Exception(mustache.sexpr.id.original + " doesn't match " + close, this);
810
    }
811
 
812
    content = new AST.ContentNode(content, locInfo);
813
 
814
    this.type = 'block';
815
    this.mustache = mustache;
816
    this.program = new AST.ProgramNode([content], {}, locInfo);
817
  },
818
 
819
  ContentNode: function(string, locInfo) {
820
    LocationInfo.call(this, locInfo);
821
    this.type = "content";
822
    this.original = this.string = string;
823
  },
824
 
825
  HashNode: function(pairs, locInfo) {
826
    LocationInfo.call(this, locInfo);
827
    this.type = "hash";
828
    this.pairs = pairs;
829
  },
830
 
831
  IdNode: function(parts, locInfo) {
832
    LocationInfo.call(this, locInfo);
833
    this.type = "ID";
834
 
835
    var original = "",
836
        dig = [],
837
        depth = 0,
838
        depthString = '';
839
 
840
    for(var i=0,l=parts.length; i<l; i++) {
841
      var part = parts[i].part;
842
      original += (parts[i].separator || '') + part;
843
 
844
      if (part === ".." || part === "." || part === "this") {
845
        if (dig.length > 0) {
846
          throw new Exception("Invalid path: " + original, this);
847
        } else if (part === "..") {
848
          depth++;
849
          depthString += '../';
850
        } else {
851
          this.isScoped = true;
852
        }
853
      } else {
854
        dig.push(part);
855
      }
856
    }
857
 
858
    this.original = original;
859
    this.parts    = dig;
860
    this.string   = dig.join('.');
861
    this.depth    = depth;
862
    this.idName   = depthString + this.string;
863
 
864
    // an ID is simple if it only has one part, and that part is not
865
    // `..` or `this`.
866
    this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;
867
 
868
    this.stringModeValue = this.string;
869
  },
870
 
871
  PartialNameNode: function(name, locInfo) {
872
    LocationInfo.call(this, locInfo);
873
    this.type = "PARTIAL_NAME";
874
    this.name = name.original;
875
  },
876
 
877
  DataNode: function(id, locInfo) {
878
    LocationInfo.call(this, locInfo);
879
    this.type = "DATA";
880
    this.id = id;
881
    this.stringModeValue = id.stringModeValue;
882
    this.idName = '@' + id.stringModeValue;
883
  },
884
 
885
  StringNode: function(string, locInfo) {
886
    LocationInfo.call(this, locInfo);
887
    this.type = "STRING";
888
    this.original =
889
      this.string =
890
      this.stringModeValue = string;
891
  },
892
 
893
  NumberNode: function(number, locInfo) {
894
    LocationInfo.call(this, locInfo);
895
    this.type = "NUMBER";
896
    this.original =
897
      this.number = number;
898
    this.stringModeValue = Number(number);
899
  },
900
 
901
  BooleanNode: function(bool, locInfo) {
902
    LocationInfo.call(this, locInfo);
903
    this.type = "BOOLEAN";
904
    this.bool = bool;
905
    this.stringModeValue = bool === "true";
906
  },
907
 
908
  CommentNode: function(comment, locInfo) {
909
    LocationInfo.call(this, locInfo);
910
    this.type = "comment";
911
    this.comment = comment;
912
 
913
    this.strip = {
914
      inlineStandalone: true
915
    };
916
  }
917
};
918
 
919
 
920
// Must be exported as an object rather than the root of the module as the jison lexer
921
// most modify the object to operate properly.
922
exports["default"] = AST;
923
}(Handlebars.AST, Handlebars.Exception));
924
Handlebars.AST = Handlebars.AST['default'];
925
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
926
(function (exports, isArray, Exception) {
927
"use strict";
928
var slice = [].slice;
929
 
930
function Compiler() {}
931
 
932
exports.Compiler = Compiler;// the foundHelper register will disambiguate helper lookup from finding a
933
// function in a context. This is necessary for mustache compatibility, which
934
// requires that context functions in blocks are evaluated by blockHelperMissing,
935
// and then proceed as if the resulting value was provided to blockHelperMissing.
936
 
937
Compiler.prototype = {
938
  compiler: Compiler,
939
 
940
  equals: function(other) {
941
    var len = this.opcodes.length;
942
    if (other.opcodes.length !== len) {
943
      return false;
944
    }
945
 
946
    for (var i = 0; i < len; i++) {
947
      var opcode = this.opcodes[i],
948
          otherOpcode = other.opcodes[i];
949
      if (opcode.opcode !== otherOpcode.opcode || !argEquals(opcode.args, otherOpcode.args)) {
950
        return false;
951
      }
952
    }
953
 
954
    // We know that length is the same between the two arrays because they are directly tied
955
    // to the opcode behavior above.
956
    len = this.children.length;
957
    for (i = 0; i < len; i++) {
958
      if (!this.children[i].equals(other.children[i])) {
959
        return false;
960
      }
961
    }
962
 
963
    return true;
964
  },
965
 
966
  guid: 0,
967
 
968
  compile: function(program, options) {
969
    this.opcodes = [];
970
    this.children = [];
971
    this.depths = {list: []};
972
    this.options = options;
973
    this.stringParams = options.stringParams;
974
    this.trackIds = options.trackIds;
975
 
976
    // These changes will propagate to the other compiler components
977
    var knownHelpers = this.options.knownHelpers;
978
    this.options.knownHelpers = {
979
      'helperMissing': true,
980
      'blockHelperMissing': true,
981
      'each': true,
982
      'if': true,
983
      'unless': true,
984
      'with': true,
985
      'log': true,
986
      'lookup': true
987
    };
988
    if (knownHelpers) {
989
      for (var name in knownHelpers) {
990
        this.options.knownHelpers[name] = knownHelpers[name];
991
      }
992
    }
993
 
994
    return this.accept(program);
995
  },
996
 
997
  accept: function(node) {
998
    return this[node.type](node);
999
  },
1000
 
1001
  program: function(program) {
1002
    var statements = program.statements;
1003
 
1004
    for(var i=0, l=statements.length; i<l; i++) {
1005
      this.accept(statements[i]);
1006
    }
1007
    this.isSimple = l === 1;
1008
 
1009
    this.depths.list = this.depths.list.sort(function(a, b) {
1010
      return a - b;
1011
    });
1012
 
1013
    return this;
1014
  },
1015
 
1016
  compileProgram: function(program) {
1017
    var result = new this.compiler().compile(program, this.options);
1018
    var guid = this.guid++, depth;
1019
 
1020
    this.usePartial = this.usePartial || result.usePartial;
1021
 
1022
    this.children[guid] = result;
1023
 
1024
    for(var i=0, l=result.depths.list.length; i<l; i++) {
1025
      depth = result.depths.list[i];
1026
 
1027
      if(depth < 2) { continue; }
1028
      else { this.addDepth(depth - 1); }
1029
    }
1030
 
1031
    return guid;
1032
  },
1033
 
1034
  block: function(block) {
1035
    var mustache = block.mustache,
1036
        program = block.program,
1037
        inverse = block.inverse;
1038
 
1039
    if (program) {
1040
      program = this.compileProgram(program);
1041
    }
1042
 
1043
    if (inverse) {
1044
      inverse = this.compileProgram(inverse);
1045
    }
1046
 
1047
    var sexpr = mustache.sexpr;
1048
    var type = this.classifySexpr(sexpr);
1049
 
1050
    if (type === "helper") {
1051
      this.helperSexpr(sexpr, program, inverse);
1052
    } else if (type === "simple") {
1053
      this.simpleSexpr(sexpr);
1054
 
1055
      // now that the simple mustache is resolved, we need to
1056
      // evaluate it by executing `blockHelperMissing`
1057
      this.opcode('pushProgram', program);
1058
      this.opcode('pushProgram', inverse);
1059
      this.opcode('emptyHash');
1060
      this.opcode('blockValue', sexpr.id.original);
1061
    } else {
1062
      this.ambiguousSexpr(sexpr, program, inverse);
1063
 
1064
      // now that the simple mustache is resolved, we need to
1065
      // evaluate it by executing `blockHelperMissing`
1066
      this.opcode('pushProgram', program);
1067
      this.opcode('pushProgram', inverse);
1068
      this.opcode('emptyHash');
1069
      this.opcode('ambiguousBlockValue');
1070
    }
1071
 
1072
    this.opcode('append');
1073
  },
1074
 
1075
  hash: function(hash) {
1076
    var pairs = hash.pairs, i, l;
1077
 
1078
    this.opcode('pushHash');
1079
 
1080
    for(i=0, l=pairs.length; i<l; i++) {
1081
      this.pushParam(pairs[i][1]);
1082
    }
1083
    while(i--) {
1084
      this.opcode('assignToHash', pairs[i][0]);
1085
    }
1086
    this.opcode('popHash');
1087
  },
1088
 
1089
  partial: function(partial) {
1090
    var partialName = partial.partialName;
1091
    this.usePartial = true;
1092
 
1093
    if (partial.hash) {
1094
      this.accept(partial.hash);
1095
    } else {
1096
      this.opcode('push', 'undefined');
1097
    }
1098
 
1099
    if (partial.context) {
1100
      this.accept(partial.context);
1101
    } else {
1102
      this.opcode('getContext', 0);
1103
      this.opcode('pushContext');
1104
    }
1105
 
1106
    this.opcode('invokePartial', partialName.name, partial.indent || '');
1107
    this.opcode('append');
1108
  },
1109
 
1110
  content: function(content) {
1111
    if (content.string) {
1112
      this.opcode('appendContent', content.string);
1113
    }
1114
  },
1115
 
1116
  mustache: function(mustache) {
1117
    this.sexpr(mustache.sexpr);
1118
 
1119
    if(mustache.escaped && !this.options.noEscape) {
1120
      this.opcode('appendEscaped');
1121
    } else {
1122
      this.opcode('append');
1123
    }
1124
  },
1125
 
1126
  ambiguousSexpr: function(sexpr, program, inverse) {
1127
    var id = sexpr.id,
1128
        name = id.parts[0],
1129
        isBlock = program != null || inverse != null;
1130
 
1131
    this.opcode('getContext', id.depth);
1132
 
1133
    this.opcode('pushProgram', program);
1134
    this.opcode('pushProgram', inverse);
1135
 
1136
    this.ID(id);
1137
 
1138
    this.opcode('invokeAmbiguous', name, isBlock);
1139
  },
1140
 
1141
  simpleSexpr: function(sexpr) {
1142
    var id = sexpr.id;
1143
 
1144
    if (id.type === 'DATA') {
1145
      this.DATA(id);
1146
    } else if (id.parts.length) {
1147
      this.ID(id);
1148
    } else {
1149
      // Simplified ID for `this`
1150
      this.addDepth(id.depth);
1151
      this.opcode('getContext', id.depth);
1152
      this.opcode('pushContext');
1153
    }
1154
 
1155
    this.opcode('resolvePossibleLambda');
1156
  },
1157
 
1158
  helperSexpr: function(sexpr, program, inverse) {
1159
    var params = this.setupFullMustacheParams(sexpr, program, inverse),
1160
        id = sexpr.id,
1161
        name = id.parts[0];
1162
 
1163
    if (this.options.knownHelpers[name]) {
1164
      this.opcode('invokeKnownHelper', params.length, name);
1165
    } else if (this.options.knownHelpersOnly) {
1166
      throw new Exception("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr);
1167
    } else {
1168
      id.falsy = true;
1169
 
1170
      this.ID(id);
1171
      this.opcode('invokeHelper', params.length, id.original, id.isSimple);
1172
    }
1173
  },
1174
 
1175
  sexpr: function(sexpr) {
1176
    var type = this.classifySexpr(sexpr);
1177
 
1178
    if (type === "simple") {
1179
      this.simpleSexpr(sexpr);
1180
    } else if (type === "helper") {
1181
      this.helperSexpr(sexpr);
1182
    } else {
1183
      this.ambiguousSexpr(sexpr);
1184
    }
1185
  },
1186
 
1187
  ID: function(id) {
1188
    this.addDepth(id.depth);
1189
    this.opcode('getContext', id.depth);
1190
 
1191
    var name = id.parts[0];
1192
    if (!name) {
1193
      // Context reference, i.e. `{{foo .}}` or `{{foo ..}}`
1194
      this.opcode('pushContext');
1195
    } else {
1196
      this.opcode('lookupOnContext', id.parts, id.falsy, id.isScoped);
1197
    }
1198
  },
1199
 
1200
  DATA: function(data) {
1201
    this.options.data = true;
1202
    this.opcode('lookupData', data.id.depth, data.id.parts);
1203
  },
1204
 
1205
  STRING: function(string) {
1206
    this.opcode('pushString', string.string);
1207
  },
1208
 
1209
  NUMBER: function(number) {
1210
    this.opcode('pushLiteral', number.number);
1211
  },
1212
 
1213
  BOOLEAN: function(bool) {
1214
    this.opcode('pushLiteral', bool.bool);
1215
  },
1216
 
1217
  comment: function() {},
1218
 
1219
  // HELPERS
1220
  opcode: function(name) {
1221
    this.opcodes.push({ opcode: name, args: slice.call(arguments, 1) });
1222
  },
1223
 
1224
  addDepth: function(depth) {
1225
    if(depth === 0) { return; }
1226
 
1227
    if(!this.depths[depth]) {
1228
      this.depths[depth] = true;
1229
      this.depths.list.push(depth);
1230
    }
1231
  },
1232
 
1233
  classifySexpr: function(sexpr) {
1234
    var isHelper   = sexpr.isHelper;
1235
    var isEligible = sexpr.eligibleHelper;
1236
    var options    = this.options;
1237
 
1238
    // if ambiguous, we can possibly resolve the ambiguity now
1239
    // An eligible helper is one that does not have a complex path, i.e. `this.foo`, `../foo` etc.
1240
    if (isEligible && !isHelper) {
1241
      var name = sexpr.id.parts[0];
1242
 
1243
      if (options.knownHelpers[name]) {
1244
        isHelper = true;
1245
      } else if (options.knownHelpersOnly) {
1246
        isEligible = false;
1247
      }
1248
    }
1249
 
1250
    if (isHelper) { return "helper"; }
1251
    else if (isEligible) { return "ambiguous"; }
1252
    else { return "simple"; }
1253
  },
1254
 
1255
  pushParams: function(params) {
1256
    for(var i=0, l=params.length; i<l; i++) {
1257
      this.pushParam(params[i]);
1258
    }
1259
  },
1260
 
1261
  pushParam: function(val) {
1262
    if (this.stringParams) {
1263
      if(val.depth) {
1264
        this.addDepth(val.depth);
1265
      }
1266
      this.opcode('getContext', val.depth || 0);
1267
      this.opcode('pushStringParam', val.stringModeValue, val.type);
1268
 
1269
      if (val.type === 'sexpr') {
1270
        // Subexpressions get evaluated and passed in
1271
        // in string params mode.
1272
        this.sexpr(val);
1273
      }
1274
    } else {
1275
      if (this.trackIds) {
1276
        this.opcode('pushId', val.type, val.idName || val.stringModeValue);
1277
      }
1278
      this.accept(val);
1279
    }
1280
  },
1281
 
1282
  setupFullMustacheParams: function(sexpr, program, inverse) {
1283
    var params = sexpr.params;
1284
    this.pushParams(params);
1285
 
1286
    this.opcode('pushProgram', program);
1287
    this.opcode('pushProgram', inverse);
1288
 
1289
    if (sexpr.hash) {
1290
      this.hash(sexpr.hash);
1291
    } else {
1292
      this.opcode('emptyHash');
1293
    }
1294
 
1295
    return params;
1296
  }
1297
};
1298
 
1299
function precompile(input, options, env) {
1300
  if (input == null || (typeof input !== 'string' && input.constructor !== env.AST.ProgramNode)) {
1301
    throw new Exception("You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input);
1302
  }
1303
 
1304
  options = options || {};
1305
  if (!('data' in options)) {
1306
    options.data = true;
1307
  }
1308
  if (options.compat) {
1309
    options.useDepths = true;
1310
  }
1311
 
1312
  var ast = env.parse(input);
1313
  var environment = new env.Compiler().compile(ast, options);
1314
  return new env.JavaScriptCompiler().compile(environment, options);
1315
}
1316
 
1317
exports.precompile = precompile;function compile(input, options, env) {
1318
  if (input == null || (typeof input !== 'string' && input.constructor !== env.AST.ProgramNode)) {
1319
    throw new Exception("You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input);
1320
  }
1321
 
1322
  options = options || {};
1323
 
1324
  if (!('data' in options)) {
1325
    options.data = true;
1326
  }
1327
  if (options.compat) {
1328
    options.useDepths = true;
1329
  }
1330
 
1331
  var compiled;
1332
 
1333
  function compileInput() {
1334
    var ast = env.parse(input);
1335
    var environment = new env.Compiler().compile(ast, options);
1336
    var templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);
1337
    return env.template(templateSpec);
1338
  }
1339
 
1340
  // Template is only compiled on first use and cached after that point.
1341
  var ret = function(context, options) {
1342
    if (!compiled) {
1343
      compiled = compileInput();
1344
    }
1345
    return compiled.call(this, context, options);
1346
  };
1347
  ret._setup = function(options) {
1348
    if (!compiled) {
1349
      compiled = compileInput();
1350
    }
1351
    return compiled._setup(options);
1352
  };
1353
  ret._child = function(i, data, depths) {
1354
    if (!compiled) {
1355
      compiled = compileInput();
1356
    }
1357
    return compiled._child(i, data, depths);
1358
  };
1359
  return ret;
1360
}
1361
 
1362
exports.compile = compile;function argEquals(a, b) {
1363
  if (a === b) {
1364
    return true;
1365
  }
1366
 
1367
  if (isArray(a) && isArray(b) && a.length === b.length) {
1368
    for (var i = 0; i < a.length; i++) {
1369
      if (!argEquals(a[i], b[i])) {
1370
        return false;
1371
      }
1372
    }
1373
    return true;
1374
  }
1375
}
1376
}(Handlebars, Handlebars.Utils.isArray, Handlebars.Exception));
1377
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
1378
Handlebars.JavaScriptCompiler = {};
1379
(function (exports, COMPILER_REVISION, REVISION_CHANGES, log, Exception) {
1380
"use strict";
1381
function Literal(value) {
1382
  this.value = value;
1383
}
1384
 
1385
function JavaScriptCompiler() {}
1386
 
1387
JavaScriptCompiler.prototype = {
1388
  // PUBLIC API: You can override these methods in a subclass to provide
1389
  // alternative compiled forms for name lookup and buffering semantics
1390
  nameLookup: function(parent, name /* , type*/) {
1391
    if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
1392
      return parent + "." + name;
1393
    } else {
1394
      return parent + "['" + name + "']";
1395
    }
1396
  },
1397
  depthedLookup: function(name) {
1398
    this.aliases.lookup = 'this.lookup';
1399
 
1400
    return 'lookup(depths, "' + name + '")';
1401
  },
1402
 
1403
  compilerInfo: function() {
1404
    var revision = COMPILER_REVISION,
1405
        versions = REVISION_CHANGES[revision];
1406
    return [revision, versions];
1407
  },
1408
 
1409
  appendToBuffer: function(string) {
1410
    if (this.environment.isSimple) {
1411
      return "return " + string + ";";
1412
    } else {
1413
      return {
1414
        appendToBuffer: true,
1415
        content: string,
1416
        toString: function() { return "buffer += " + string + ";"; }
1417
      };
1418
    }
1419
  },
1420
 
1421
  initializeBuffer: function() {
1422
    return this.quotedString("");
1423
  },
1424
 
1425
  namespace: "Handlebars",
1426
  // END PUBLIC API
1427
 
1428
  compile: function(environment, options, context, asObject) {
1429
    this.environment = environment;
1430
    this.options = options;
1431
    this.stringParams = this.options.stringParams;
1432
    this.trackIds = this.options.trackIds;
1433
    this.precompile = !asObject;
1434
 
1435
    this.name = this.environment.name;
1436
    this.isChild = !!context;
1437
    this.context = context || {
1438
      programs: [],
1439
      environments: []
1440
    };
1441
 
1442
    this.preamble();
1443
 
1444
    this.stackSlot = 0;
1445
    this.stackVars = [];
1446
    this.aliases = {};
1447
    this.registers = { list: [] };
1448
    this.hashes = [];
1449
    this.compileStack = [];
1450
    this.inlineStack = [];
1451
 
1452
    this.compileChildren(environment, options);
1453
 
1454
    this.useDepths = this.useDepths || environment.depths.list.length || this.options.compat;
1455
 
1456
    var opcodes = environment.opcodes,
1457
        opcode,
1458
        i,
1459
        l;
1460
 
1461
    for (i = 0, l = opcodes.length; i < l; i++) {
1462
      opcode = opcodes[i];
1463
 
1464
      this[opcode.opcode].apply(this, opcode.args);
1465
    }
1466
 
1467
    // Flush any trailing content that might be pending.
1468
    this.pushSource('');
1469
 
1470
    /* istanbul ignore next */
1471
    if (this.stackSlot || this.inlineStack.length || this.compileStack.length) {
1472
      throw new Exception('Compile completed with content left on stack');
1473
    }
1474
 
1475
    var fn = this.createFunctionContext(asObject);
1476
    if (!this.isChild) {
1477
      var ret = {
1478
        compiler: this.compilerInfo(),
1479
        main: fn
1480
      };
1481
      var programs = this.context.programs;
1482
      for (i = 0, l = programs.length; i < l; i++) {
1483
        if (programs[i]) {
1484
          ret[i] = programs[i];
1485
        }
1486
      }
1487
 
1488
      if (this.environment.usePartial) {
1489
        ret.usePartial = true;
1490
      }
1491
      if (this.options.data) {
1492
        ret.useData = true;
1493
      }
1494
      if (this.useDepths) {
1495
        ret.useDepths = true;
1496
      }
1497
      if (this.options.compat) {
1498
        ret.compat = true;
1499
      }
1500
 
1501
      if (!asObject) {
1502
        ret.compiler = JSON.stringify(ret.compiler);
1503
        ret = this.objectLiteral(ret);
1504
      }
1505
 
1506
      return ret;
1507
    } else {
1508
      return fn;
1509
    }
1510
  },
1511
 
1512
  preamble: function() {
1513
    // track the last context pushed into place to allow skipping the
1514
    // getContext opcode when it would be a noop
1515
    this.lastContext = 0;
1516
    this.source = [];
1517
  },
1518
 
1519
  createFunctionContext: function(asObject) {
1520
    var varDeclarations = '';
1521
 
1522
    var locals = this.stackVars.concat(this.registers.list);
1523
    if(locals.length > 0) {
1524
      varDeclarations += ", " + locals.join(", ");
1525
    }
1526
 
1527
    // Generate minimizer alias mappings
1528
    for (var alias in this.aliases) {
1529
      if (this.aliases.hasOwnProperty(alias)) {
1530
        varDeclarations += ', ' + alias + '=' + this.aliases[alias];
1531
      }
1532
    }
1533
 
1534
    var params = ["depth0", "helpers", "partials", "data"];
1535
 
1536
    if (this.useDepths) {
1537
      params.push('depths');
1538
    }
1539
 
1540
    // Perform a second pass over the output to merge content when possible
1541
    var source = this.mergeSource(varDeclarations);
1542
 
1543
    if (asObject) {
1544
      params.push(source);
1545
 
1546
      return Function.apply(this, params);
1547
    } else {
1548
      return 'function(' + params.join(',') + ') {\n  ' + source + '}';
1549
    }
1550
  },
1551
  mergeSource: function(varDeclarations) {
1552
    var source = '',
1553
        buffer,
1554
        appendOnly = !this.forceBuffer,
1555
        appendFirst;
1556
 
1557
    for (var i = 0, len = this.source.length; i < len; i++) {
1558
      var line = this.source[i];
1559
      if (line.appendToBuffer) {
1560
        if (buffer) {
1561
          buffer = buffer + '\n    + ' + line.content;
1562
        } else {
1563
          buffer = line.content;
1564
        }
1565
      } else {
1566
        if (buffer) {
1567
          if (!source) {
1568
            appendFirst = true;
1569
            source = buffer + ';\n  ';
1570
          } else {
1571
            source += 'buffer += ' + buffer + ';\n  ';
1572
          }
1573
          buffer = undefined;
1574
        }
1575
        source += line + '\n  ';
1576
 
1577
        if (!this.environment.isSimple) {
1578
          appendOnly = false;
1579
        }
1580
      }
1581
    }
1582
 
1583
    if (appendOnly) {
1584
      if (buffer || !source) {
1585
        source += 'return ' + (buffer || '""') + ';\n';
1586
      }
1587
    } else {
1588
      varDeclarations += ", buffer = " + (appendFirst ? '' : this.initializeBuffer());
1589
      if (buffer) {
1590
        source += 'return buffer + ' + buffer + ';\n';
1591
      } else {
1592
        source += 'return buffer;\n';
1593
      }
1594
    }
1595
 
1596
    if (varDeclarations) {
1597
      source = 'var ' + varDeclarations.substring(2) + (appendFirst ? '' : ';\n  ') + source;
1598
    }
1599
 
1600
    return source;
1601
  },
1602
 
1603
  // [blockValue]
1604
  //
1605
  // On stack, before: hash, inverse, program, value
1606
  // On stack, after: return value of blockHelperMissing
1607
  //
1608
  // The purpose of this opcode is to take a block of the form
1609
  // `{{#this.foo}}...{{/this.foo}}`, resolve the value of `foo`, and
1610
  // replace it on the stack with the result of properly
1611
  // invoking blockHelperMissing.
1612
  blockValue: function(name) {
1613
    this.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
1614
 
1615
    var params = [this.contextName(0)];
1616
    this.setupParams(name, 0, params);
1617
 
1618
    var blockName = this.popStack();
1619
    params.splice(1, 0, blockName);
1620
 
1621
    this.push('blockHelperMissing.call(' + params.join(', ') + ')');
1622
  },
1623
 
1624
  // [ambiguousBlockValue]
1625
  //
1626
  // On stack, before: hash, inverse, program, value
1627
  // Compiler value, before: lastHelper=value of last found helper, if any
1628
  // On stack, after, if no lastHelper: same as [blockValue]
1629
  // On stack, after, if lastHelper: value
1630
  ambiguousBlockValue: function() {
1631
    this.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
1632
 
1633
    // We're being a bit cheeky and reusing the options value from the prior exec
1634
    var params = [this.contextName(0)];
1635
    this.setupParams('', 0, params, true);
1636
 
1637
    this.flushInline();
1638
 
1639
    var current = this.topStack();
1640
    params.splice(1, 0, current);
1641
 
1642
    this.pushSource("if (!" + this.lastHelper + ") { " + current + " = blockHelperMissing.call(" + params.join(", ") + "); }");
1643
  },
1644
 
1645
  // [appendContent]
1646
  //
1647
  // On stack, before: ...
1648
  // On stack, after: ...
1649
  //
1650
  // Appends the string value of `content` to the current buffer
1651
  appendContent: function(content) {
1652
    if (this.pendingContent) {
1653
      content = this.pendingContent + content;
1654
    }
1655
 
1656
    this.pendingContent = content;
1657
  },
1658
 
1659
  // [append]
1660
  //
1661
  // On stack, before: value, ...
1662
  // On stack, after: ...
1663
  //
1664
  // Coerces `value` to a String and appends it to the current buffer.
1665
  //
1666
  // If `value` is truthy, or 0, it is coerced into a string and appended
1667
  // Otherwise, the empty string is appended
1668
  append: function() {
1669
    // Force anything that is inlined onto the stack so we don't have duplication
1670
    // when we examine local
1671
    this.flushInline();
1672
    var local = this.popStack();
1673
    this.pushSource('if (' + local + ' != null) { ' + this.appendToBuffer(local) + ' }');
1674
    if (this.environment.isSimple) {
1675
      this.pushSource("else { " + this.appendToBuffer("''") + " }");
1676
    }
1677
  },
1678
 
1679
  // [appendEscaped]
1680
  //
1681
  // On stack, before: value, ...
1682
  // On stack, after: ...
1683
  //
1684
  // Escape `value` and append it to the buffer
1685
  appendEscaped: function() {
1686
    this.aliases.escapeExpression = 'this.escapeExpression';
1687
 
1688
    this.pushSource(this.appendToBuffer("escapeExpression(" + this.popStack() + ")"));
1689
  },
1690
 
1691
  // [getContext]
1692
  //
1693
  // On stack, before: ...
1694
  // On stack, after: ...
1695
  // Compiler value, after: lastContext=depth
1696
  //
1697
  // Set the value of the `lastContext` compiler value to the depth
1698
  getContext: function(depth) {
1699
    this.lastContext = depth;
1700
  },
1701
 
1702
  // [pushContext]
1703
  //
1704
  // On stack, before: ...
1705
  // On stack, after: currentContext, ...
1706
  //
1707
  // Pushes the value of the current context onto the stack.
1708
  pushContext: function() {
1709
    this.pushStackLiteral(this.contextName(this.lastContext));
1710
  },
1711
 
1712
  // [lookupOnContext]
1713
  //
1714
  // On stack, before: ...
1715
  // On stack, after: currentContext[name], ...
1716
  //
1717
  // Looks up the value of `name` on the current context and pushes
1718
  // it onto the stack.
1719
  lookupOnContext: function(parts, falsy, scoped) {
1720
    /*jshint -W083 */
1721
    var i = 0,
1722
        len = parts.length;
1723
 
1724
    if (!scoped && this.options.compat && !this.lastContext) {
1725
      // The depthed query is expected to handle the undefined logic for the root level that
1726
      // is implemented below, so we evaluate that directly in compat mode
1727
      this.push(this.depthedLookup(parts[i++]));
1728
    } else {
1729
      this.pushContext();
1730
    }
1731
 
1732
    for (; i < len; i++) {
1733
      this.replaceStack(function(current) {
1734
        var lookup = this.nameLookup(current, parts[i], 'context');
1735
        // We want to ensure that zero and false are handled properly if the context (falsy flag)
1736
        // needs to have the special handling for these values.
1737
        if (!falsy) {
1738
          return ' != null ? ' + lookup + ' : ' + current;
1739
        } else {
1740
          // Otherwise we can use generic falsy handling
1741
          return ' && ' + lookup;
1742
        }
1743
      });
1744
    }
1745
  },
1746
 
1747
  // [lookupData]
1748
  //
1749
  // On stack, before: ...
1750
  // On stack, after: data, ...
1751
  //
1752
  // Push the data lookup operator
1753
  lookupData: function(depth, parts) {
1754
    /*jshint -W083 */
1755
    if (!depth) {
1756
      this.pushStackLiteral('data');
1757
    } else {
1758
      this.pushStackLiteral('this.data(data, ' + depth + ')');
1759
    }
1760
 
1761
    var len = parts.length;
1762
    for (var i = 0; i < len; i++) {
1763
      this.replaceStack(function(current) {
1764
        return ' && ' + this.nameLookup(current, parts[i], 'data');
1765
      });
1766
    }
1767
  },
1768
 
1769
  // [resolvePossibleLambda]
1770
  //
1771
  // On stack, before: value, ...
1772
  // On stack, after: resolved value, ...
1773
  //
1774
  // If the `value` is a lambda, replace it on the stack by
1775
  // the return value of the lambda
1776
  resolvePossibleLambda: function() {
1777
    this.aliases.lambda = 'this.lambda';
1778
 
1779
    this.push('lambda(' + this.popStack() + ', ' + this.contextName(0) + ')');
1780
  },
1781
 
1782
  // [pushStringParam]
1783
  //
1784
  // On stack, before: ...
1785
  // On stack, after: string, currentContext, ...
1786
  //
1787
  // This opcode is designed for use in string mode, which
1788
  // provides the string value of a parameter along with its
1789
  // depth rather than resolving it immediately.
1790
  pushStringParam: function(string, type) {
1791
    this.pushContext();
1792
    this.pushString(type);
1793
 
1794
    // If it's a subexpression, the string result
1795
    // will be pushed after this opcode.
1796
    if (type !== 'sexpr') {
1797
      if (typeof string === 'string') {
1798
        this.pushString(string);
1799
      } else {
1800
        this.pushStackLiteral(string);
1801
      }
1802
    }
1803
  },
1804
 
1805
  emptyHash: function() {
1806
    this.pushStackLiteral('{}');
1807
 
1808
    if (this.trackIds) {
1809
      this.push('{}'); // hashIds
1810
    }
1811
    if (this.stringParams) {
1812
      this.push('{}'); // hashContexts
1813
      this.push('{}'); // hashTypes
1814
    }
1815
  },
1816
  pushHash: function() {
1817
    if (this.hash) {
1818
      this.hashes.push(this.hash);
1819
    }
1820
    this.hash = {values: [], types: [], contexts: [], ids: []};
1821
  },
1822
  popHash: function() {
1823
    var hash = this.hash;
1824
    this.hash = this.hashes.pop();
1825
 
1826
    if (this.trackIds) {
1827
      this.push('{' + hash.ids.join(',') + '}');
1828
    }
1829
    if (this.stringParams) {
1830
      this.push('{' + hash.contexts.join(',') + '}');
1831
      this.push('{' + hash.types.join(',') + '}');
1832
    }
1833
 
1834
    this.push('{\n    ' + hash.values.join(',\n    ') + '\n  }');
1835
  },
1836
 
1837
  // [pushString]
1838
  //
1839
  // On stack, before: ...
1840
  // On stack, after: quotedString(string), ...
1841
  //
1842
  // Push a quoted version of `string` onto the stack
1843
  pushString: function(string) {
1844
    this.pushStackLiteral(this.quotedString(string));
1845
  },
1846
 
1847
  // [push]
1848
  //
1849
  // On stack, before: ...
1850
  // On stack, after: expr, ...
1851
  //
1852
  // Push an expression onto the stack
1853
  push: function(expr) {
1854
    this.inlineStack.push(expr);
1855
    return expr;
1856
  },
1857
 
1858
  // [pushLiteral]
1859
  //
1860
  // On stack, before: ...
1861
  // On stack, after: value, ...
1862
  //
1863
  // Pushes a value onto the stack. This operation prevents
1864
  // the compiler from creating a temporary variable to hold
1865
  // it.
1866
  pushLiteral: function(value) {
1867
    this.pushStackLiteral(value);
1868
  },
1869
 
1870
  // [pushProgram]
1871
  //
1872
  // On stack, before: ...
1873
  // On stack, after: program(guid), ...
1874
  //
1875
  // Push a program expression onto the stack. This takes
1876
  // a compile-time guid and converts it into a runtime-accessible
1877
  // expression.
1878
  pushProgram: function(guid) {
1879
    if (guid != null) {
1880
      this.pushStackLiteral(this.programExpression(guid));
1881
    } else {
1882
      this.pushStackLiteral(null);
1883
    }
1884
  },
1885
 
1886
  // [invokeHelper]
1887
  //
1888
  // On stack, before: hash, inverse, program, params..., ...
1889
  // On stack, after: result of helper invocation
1890
  //
1891
  // Pops off the helper's parameters, invokes the helper,
1892
  // and pushes the helper's return value onto the stack.
1893
  //
1894
  // If the helper is not found, `helperMissing` is called.
1895
  invokeHelper: function(paramSize, name, isSimple) {
1896
    this.aliases.helperMissing = 'helpers.helperMissing';
1897
 
1898
    var nonHelper = this.popStack();
1899
    var helper = this.setupHelper(paramSize, name);
1900
 
1901
    var lookup = (isSimple ? helper.name + ' || ' : '') + nonHelper + ' || helperMissing';
1902
    this.push('((' + lookup + ').call(' + helper.callParams + '))');
1903
  },
1904
 
1905
  // [invokeKnownHelper]
1906
  //
1907
  // On stack, before: hash, inverse, program, params..., ...
1908
  // On stack, after: result of helper invocation
1909
  //
1910
  // This operation is used when the helper is known to exist,
1911
  // so a `helperMissing` fallback is not required.
1912
  invokeKnownHelper: function(paramSize, name) {
1913
    var helper = this.setupHelper(paramSize, name);
1914
    this.push(helper.name + ".call(" + helper.callParams + ")");
1915
  },
1916
 
1917
  // [invokeAmbiguous]
1918
  //
1919
  // On stack, before: hash, inverse, program, params..., ...
1920
  // On stack, after: result of disambiguation
1921
  //
1922
  // This operation is used when an expression like `{{foo}}`
1923
  // is provided, but we don't know at compile-time whether it
1924
  // is a helper or a path.
1925
  //
1926
  // This operation emits more code than the other options,
1927
  // and can be avoided by passing the `knownHelpers` and
1928
  // `knownHelpersOnly` flags at compile-time.
1929
  invokeAmbiguous: function(name, helperCall) {
1930
    this.aliases.functionType = '"function"';
1931
    this.aliases.helperMissing = 'helpers.helperMissing';
1932
    this.useRegister('helper');
1933
 
1934
    var nonHelper = this.popStack();
1935
 
1936
    this.emptyHash();
1937
    var helper = this.setupHelper(0, name, helperCall);
1938
 
1939
    var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper');
1940
 
1941
    this.push(
1942
      '((helper = (helper = ' + helperName + ' || ' + nonHelper + ') != null ? helper : helperMissing'
1943
        + (helper.paramsInit ? '),(' + helper.paramsInit : '') + '),'
1944
      + '(typeof helper === functionType ? helper.call(' + helper.callParams + ') : helper))');
1945
  },
1946
 
1947
  // [invokePartial]
1948
  //
1949
  // On stack, before: context, ...
1950
  // On stack after: result of partial invocation
1951
  //
1952
  // This operation pops off a context, invokes a partial with that context,
1953
  // and pushes the result of the invocation back.
1954
  invokePartial: function(name, indent) {
1955
    var params = [this.nameLookup('partials', name, 'partial'), "'" + indent + "'", "'" + name + "'", this.popStack(), this.popStack(), "helpers", "partials"];
1956
 
1957
    if (this.options.data) {
1958
      params.push("data");
1959
    } else if (this.options.compat) {
1960
      params.push('undefined');
1961
    }
1962
    if (this.options.compat) {
1963
      params.push('depths');
1964
    }
1965
 
1966
    this.push("this.invokePartial(" + params.join(", ") + ")");
1967
  },
1968
 
1969
  // [assignToHash]
1970
  //
1971
  // On stack, before: value, ..., hash, ...
1972
  // On stack, after: ..., hash, ...
1973
  //
1974
  // Pops a value off the stack and assigns it to the current hash
1975
  assignToHash: function(key) {
1976
    var value = this.popStack(),
1977
        context,
1978
        type,
1979
        id;
1980
 
1981
    if (this.trackIds) {
1982
      id = this.popStack();
1983
    }
1984
    if (this.stringParams) {
1985
      type = this.popStack();
1986
      context = this.popStack();
1987
    }
1988
 
1989
    var hash = this.hash;
1990
    if (context) {
1991
      hash.contexts.push("'" + key + "': " + context);
1992
    }
1993
    if (type) {
1994
      hash.types.push("'" + key + "': " + type);
1995
    }
1996
    if (id) {
1997
      hash.ids.push("'" + key + "': " + id);
1998
    }
1999
    hash.values.push("'" + key + "': (" + value + ")");
2000
  },
2001
 
2002
  pushId: function(type, name) {
2003
    if (type === 'ID' || type === 'DATA') {
2004
      this.pushString(name);
2005
    } else if (type === 'sexpr') {
2006
      this.pushStackLiteral('true');
2007
    } else {
2008
      this.pushStackLiteral('null');
2009
    }
2010
  },
2011
 
2012
  // HELPERS
2013
 
2014
  compiler: JavaScriptCompiler,
2015
 
2016
  compileChildren: function(environment, options) {
2017
    var children = environment.children, child, compiler;
2018
 
2019
    for(var i=0, l=children.length; i<l; i++) {
2020
      child = children[i];
2021
      compiler = new this.compiler();
2022
 
2023
      var index = this.matchExistingProgram(child);
2024
 
2025
      if (index == null) {
2026
        this.context.programs.push('');     // Placeholder to prevent name conflicts for nested children
2027
        index = this.context.programs.length;
2028
        child.index = index;
2029
        child.name = 'program' + index;
2030
        this.context.programs[index] = compiler.compile(child, options, this.context, !this.precompile);
2031
        this.context.environments[index] = child;
2032
 
2033
        this.useDepths = this.useDepths || compiler.useDepths;
2034
      } else {
2035
        child.index = index;
2036
        child.name = 'program' + index;
2037
      }
2038
    }
2039
  },
2040
  matchExistingProgram: function(child) {
2041
    for (var i = 0, len = this.context.environments.length; i < len; i++) {
2042
      var environment = this.context.environments[i];
2043
      if (environment && environment.equals(child)) {
2044
        return i;
2045
      }
2046
    }
2047
  },
2048
 
2049
  programExpression: function(guid) {
2050
    var child = this.environment.children[guid],
2051
        depths = child.depths.list,
2052
        useDepths = this.useDepths,
2053
        depth;
2054
 
2055
    var programParams = [child.index, 'data'];
2056
 
2057
    if (useDepths) {
2058
      programParams.push('depths');
2059
    }
2060
 
2061
    return 'this.program(' + programParams.join(', ') + ')';
2062
  },
2063
 
2064
  useRegister: function(name) {
2065
    if(!this.registers[name]) {
2066
      this.registers[name] = true;
2067
      this.registers.list.push(name);
2068
    }
2069
  },
2070
 
2071
  pushStackLiteral: function(item) {
2072
    return this.push(new Literal(item));
2073
  },
2074
 
2075
  pushSource: function(source) {
2076
    if (this.pendingContent) {
2077
      this.source.push(this.appendToBuffer(this.quotedString(this.pendingContent)));
2078
      this.pendingContent = undefined;
2079
    }
2080
 
2081
    if (source) {
2082
      this.source.push(source);
2083
    }
2084
  },
2085
 
2086
  pushStack: function(item) {
2087
    this.flushInline();
2088
 
2089
    var stack = this.incrStack();
2090
    this.pushSource(stack + " = " + item + ";");
2091
    this.compileStack.push(stack);
2092
    return stack;
2093
  },
2094
 
2095
  replaceStack: function(callback) {
2096
    var prefix = '',
2097
        inline = this.isInline(),
2098
        stack,
2099
        createdStack,
2100
        usedLiteral;
2101
 
2102
    /* istanbul ignore next */
2103
    if (!this.isInline()) {
2104
      throw new Exception('replaceStack on non-inline');
2105
    }
2106
 
2107
    // We want to merge the inline statement into the replacement statement via ','
2108
    var top = this.popStack(true);
2109
 
2110
    if (top instanceof Literal) {
2111
      // Literals do not need to be inlined
2112
      prefix = stack = top.value;
2113
      usedLiteral = true;
2114
    } else {
2115
      // Get or create the current stack name for use by the inline
2116
      createdStack = !this.stackSlot;
2117
      var name = !createdStack ? this.topStackName() : this.incrStack();
2118
 
2119
      prefix = '(' + this.push(name) + ' = ' + top + ')';
2120
      stack = this.topStack();
2121
    }
2122
 
2123
    var item = callback.call(this, stack);
2124
 
2125
    if (!usedLiteral) {
2126
      this.popStack();
2127
    }
2128
    if (createdStack) {
2129
      this.stackSlot--;
2130
    }
2131
    this.push('(' + prefix + item + ')');
2132
  },
2133
 
2134
  incrStack: function() {
2135
    this.stackSlot++;
2136
    if(this.stackSlot > this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); }
2137
    return this.topStackName();
2138
  },
2139
  topStackName: function() {
2140
    return "stack" + this.stackSlot;
2141
  },
2142
  flushInline: function() {
2143
    var inlineStack = this.inlineStack;
2144
    if (inlineStack.length) {
2145
      this.inlineStack = [];
2146
      for (var i = 0, len = inlineStack.length; i < len; i++) {
2147
        var entry = inlineStack[i];
2148
        if (entry instanceof Literal) {
2149
          this.compileStack.push(entry);
2150
        } else {
2151
          this.pushStack(entry);
2152
        }
2153
      }
2154
    }
2155
  },
2156
  isInline: function() {
2157
    return this.inlineStack.length;
2158
  },
2159
 
2160
  popStack: function(wrapped) {
2161
    var inline = this.isInline(),
2162
        item = (inline ? this.inlineStack : this.compileStack).pop();
2163
 
2164
    if (!wrapped && (item instanceof Literal)) {
2165
      return item.value;
2166
    } else {
2167
      if (!inline) {
2168
        /* istanbul ignore next */
2169
        if (!this.stackSlot) {
2170
          throw new Exception('Invalid stack pop');
2171
        }
2172
        this.stackSlot--;
2173
      }
2174
      return item;
2175
    }
2176
  },
2177
 
2178
  topStack: function() {
2179
    var stack = (this.isInline() ? this.inlineStack : this.compileStack),
2180
        item = stack[stack.length - 1];
2181
 
2182
    if (item instanceof Literal) {
2183
      return item.value;
2184
    } else {
2185
      return item;
2186
    }
2187
  },
2188
 
2189
  contextName: function(context) {
2190
    if (this.useDepths && context) {
2191
      return 'depths[' + context + ']';
2192
    } else {
2193
      return 'depth' + context;
2194
    }
2195
  },
2196
 
2197
  quotedString: function(str) {
2198
    return '"' + str
2199
      .replace(/\\/g, '\\\\')
2200
      .replace(/"/g, '\\"')
2201
      .replace(/\n/g, '\\n')
2202
      .replace(/\r/g, '\\r')
2203
      .replace(/\u2028/g, '\\u2028')   // Per Ecma-262 7.3 + 7.8.4
2204
      .replace(/\u2029/g, '\\u2029') + '"';
2205
  },
2206
 
2207
  objectLiteral: function(obj) {
2208
    var pairs = [];
2209
 
2210
    for (var key in obj) {
2211
      if (obj.hasOwnProperty(key)) {
2212
        pairs.push(this.quotedString(key) + ':' + obj[key]);
2213
      }
2214
    }
2215
 
2216
    return '{' + pairs.join(',') + '}';
2217
  },
2218
 
2219
  setupHelper: function(paramSize, name, blockHelper) {
2220
    var params = [],
2221
        paramsInit = this.setupParams(name, paramSize, params, blockHelper);
2222
    var foundHelper = this.nameLookup('helpers', name, 'helper');
2223
 
2224
    return {
2225
      params: params,
2226
      paramsInit: paramsInit,
2227
      name: foundHelper,
2228
      callParams: [this.contextName(0)].concat(params).join(", ")
2229
    };
2230
  },
2231
 
2232
  setupOptions: function(helper, paramSize, params) {
2233
    var options = {}, contexts = [], types = [], ids = [], param, inverse, program;
2234
 
2235
    options.name = this.quotedString(helper);
2236
    options.hash = this.popStack();
2237
 
2238
    if (this.trackIds) {
2239
      options.hashIds = this.popStack();
2240
    }
2241
    if (this.stringParams) {
2242
      options.hashTypes = this.popStack();
2243
      options.hashContexts = this.popStack();
2244
    }
2245
 
2246
    inverse = this.popStack();
2247
    program = this.popStack();
2248
 
2249
    // Avoid setting fn and inverse if neither are set. This allows
2250
    // helpers to do a check for `if (options.fn)`
2251
    if (program || inverse) {
2252
      if (!program) {
2253
        program = 'this.noop';
2254
      }
2255
 
2256
      if (!inverse) {
2257
        inverse = 'this.noop';
2258
      }
2259
 
2260
      options.fn = program;
2261
      options.inverse = inverse;
2262
    }
2263
 
2264
    // The parameters go on to the stack in order (making sure that they are evaluated in order)
2265
    // so we need to pop them off the stack in reverse order
2266
    var i = paramSize;
2267
    while (i--) {
2268
      param = this.popStack();
2269
      params[i] = param;
2270
 
2271
      if (this.trackIds) {
2272
        ids[i] = this.popStack();
2273
      }
2274
      if (this.stringParams) {
2275
        types[i] = this.popStack();
2276
        contexts[i] = this.popStack();
2277
      }
2278
    }
2279
 
2280
    if (this.trackIds) {
2281
      options.ids = "[" + ids.join(",") + "]";
2282
    }
2283
    if (this.stringParams) {
2284
      options.types = "[" + types.join(",") + "]";
2285
      options.contexts = "[" + contexts.join(",") + "]";
2286
    }
2287
 
2288
    if (this.options.data) {
2289
      options.data = "data";
2290
    }
2291
 
2292
    return options;
2293
  },
2294
 
2295
  // the params and contexts arguments are passed in arrays
2296
  // to fill in
2297
  setupParams: function(helperName, paramSize, params, useRegister) {
2298
    var options = this.objectLiteral(this.setupOptions(helperName, paramSize, params));
2299
 
2300
    if (useRegister) {
2301
      this.useRegister('options');
2302
      params.push('options');
2303
      return 'options=' + options;
2304
    } else {
2305
      params.push(options);
2306
      return '';
2307
    }
2308
  }
2309
};
2310
 
2311
var reservedWords = (
2312
  "break else new var" +
2313
  " case finally return void" +
2314
  " catch for switch while" +
2315
  " continue function this with" +
2316
  " default if throw" +
2317
  " delete in try" +
2318
  " do instanceof typeof" +
2319
  " abstract enum int short" +
2320
  " boolean export interface static" +
2321
  " byte extends long super" +
2322
  " char final native synchronized" +
2323
  " class float package throws" +
2324
  " const goto private transient" +
2325
  " debugger implements protected volatile" +
2326
  " double import public let yield"
2327
).split(" ");
2328
 
2329
var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
2330
 
2331
for(var i=0, l=reservedWords.length; i<l; i++) {
2332
  compilerWords[reservedWords[i]] = true;
2333
}
2334
 
2335
JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
2336
  return !JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(name);
2337
};
2338
 
2339
exports["default"] = JavaScriptCompiler;
2340
}(Handlebars.JavaScriptCompiler, Handlebars.COMPILER_REVISION, Handlebars.REVISION_CHANGES, Handlebars.log, Handlebars.Exception));
2341
Handlebars.JavaScriptCompiler = Handlebars.JavaScriptCompiler['default'];
2342
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
2343
(function (exports, parser, AST, extend, Helpers) {
2344
"use strict";
2345
exports.parser = parser;
2346
 
2347
var yy = {};
2348
extend(yy, Helpers, AST);
2349
 
2350
function parse(input) {
2351
  // Just return if an already-compile AST was passed in.
2352
  if (input.constructor === AST.ProgramNode) { return input; }
2353
 
2354
  parser.yy = yy;
2355
 
2356
  return parser.parse(input);
2357
}
2358
 
2359
exports.parse = parse;
2360
}(Handlebars, Handlebars.Parser, Handlebars.AST, Handlebars.Utils.extend, Handlebars.Helpers));
2361
// This file contains YUI-specific wrapper code and overrides for the
2362
// handlebars-compiler module.
2363
 
2364
/**
2365
Handlebars parser and compiler. Use this module when you need to compile
2366
Handlebars templates.
2367
 
2368
@module handlebars
2369
@submodule handlebars-compiler
2370
*/
2371
 
2372
var levels = ['debug', 'info', 'warn', 'error'];
2373
 
2374
/**
2375
Logs a debugging message. Note that messages will only be logged when the
2376
handlebars module is loaded in "debug" mode.
2377
 
2378
@method log
2379
@param {String} level Log level for this message. Supported levels are "debug",
2380
    "info", "warn", and "error".
2381
@param {String} message Message to log.
2382
@for Handlebars
2383
*/
2384
Handlebars.logger.log = function (level, message) {
2385
    Y.log(message, levels[level] || 'error', 'Handlebars');
2386
};
2387
 
2388
/**
2389
Compiles and renders a Handlebars template string in a single step.
2390
 
2391
If you'll be using a template more than once, it's more efficient to compile it
2392
into a function once using `compile()`, and then render it whenever you need to
2393
by simply executing the compiled function. However, if you only need to compile
2394
and render a template once, `render()` is a handy shortcut for doing both in a
2395
single step.
2396
 
2397
@example
2398
 
2399
    Y.Handlebars.render('The pie of the day is {{pie}}!', {
2400
        pie: 'Maple Custard'
2401
    });
2402
    // => "The pie of the day is Maple Custard!"
2403
 
2404
@method render
2405
@param {String} string Handlebars template string to render.
2406
@param {Object} context Context object to pass to the template.
2407
@param {Object} [options] Compile/render options.
2408
    @param {Object} [options.helpers] Helper functions.
2409
    @param {Object} [options.partials] Partials.
2410
    @param {Object} [options.data] Data.
2411
@return {String} Rendered template string.
2412
*/
2413
Handlebars.render = function (string, context, options) {
2414
    return this.compile(string)(context, options);
2415
};
2416
 
2417
// The rest of this file is just API docs for methods defined in Handlebars
2418
// itself.
2419
 
2420
/**
2421
Compiles a Handlebars template string into a function. To render the template,
2422
call the function and pass in a context object.
2423
 
2424
@example
2425
 
2426
    var template = Y.Handlebars.compile('The pie of the day is {{pie}}!.');
2427
    template({pie: 'Pecan'});
2428
    // => "The pie of the day is Pecan!"
2429
 
2430
@method compile
2431
@param {String} string Handlebars template string to compile.
2432
@param {Object} [options] Compiler options.
2433
@return {Function} Compiled template function.
2434
*/
2435
 
2436
/**
2437
Precompiles a Handlebars template string into a string of JavaScript code. This
2438
can be used to precompile a template at build time or on the server, and the
2439
resulting template can then be rendered at runtime or on the client without
2440
needing to go through a compile step.
2441
 
2442
To render a precompiled template, evaluate the code and then pass the resulting
2443
function to `Y.Handlebars.template()` to get back an executable template
2444
function.
2445
 
2446
@method precompile
2447
@param {String} string Handlebars template string to compile.
2448
@param {Object} [options] Compiler options.
2449
@return {String} Precompiled template code.
2450
*/
2451
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
2452
Handlebars.Runtime = {};
2453
(function (exports, base, SafeString, Exception, Utils, runtime) {
2454
"use strict";
2455
/*globals Handlebars: true */
2456
// Each of these augment the Handlebars object. No need to setup here.
2457
// (This is done to easily share code between commonjs and browse envs)
2458
// For compatibility and usage outside of module systems, make the Handlebars object a namespace
2459
var create = function() {
2460
  var hb = new base.HandlebarsEnvironment();
2461
 
2462
  Utils.extend(hb, base);
2463
  hb.SafeString = SafeString;
2464
  hb.Exception = Exception;
2465
  hb.Utils = Utils;
2466
  hb.escapeExpression = Utils.escapeExpression;
2467
 
2468
  hb.VM = runtime;
2469
  hb.template = function(spec) {
2470
    return runtime.template(spec, hb);
2471
  };
2472
 
2473
  return hb;
2474
};
2475
 
2476
var Handlebars = create();
2477
Handlebars.create = create;
2478
 
2479
Handlebars['default'] = Handlebars;
2480
 
2481
exports["default"] = Handlebars;
2482
}(Handlebars.Runtime, Handlebars, Handlebars.SafeString, Handlebars.Exception, Handlebars.Utils, Handlebars.VM));
2483
Handlebars.Runtime = Handlebars.Runtime['default'];
2484
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
2485
(function (exports, Handlebars, AST, Parser, parse, Compiler, compile, precompile, JavaScriptCompiler) {
2486
"use strict";
2487
/*globals Handlebars: true */
2488
// Compiler imports
2489
var _create = Handlebars.create;
2490
var create = function() {
2491
  var hb = _create();
2492
 
2493
  hb.compile = function(input, options) {
2494
    return compile(input, options, hb);
2495
  };
2496
  hb.precompile = function (input, options) {
2497
    return precompile(input, options, hb);
2498
  };
2499
 
2500
  hb.AST = AST;
2501
  hb.Compiler = Compiler;
2502
  hb.JavaScriptCompiler = JavaScriptCompiler;
2503
  hb.Parser = Parser;
2504
  hb.parse = parse;
2505
 
2506
  return hb;
2507
};
2508
 
2509
Handlebars = create();
2510
Handlebars.create = create;
2511
 
2512
Handlebars['default'] = Handlebars;
2513
 
2514
exports["default"] = Handlebars;
2515
}(Handlebars, Handlebars.Runtime, Handlebars.AST, Handlebars.Parser, Handlebars.parse, Handlebars.Compiler, Handlebars.compile, Handlebars.precompile, Handlebars.JavaScriptCompiler));
2516
Y.Handlebars = Handlebars['default'];
2517
 
2518
 
2519
}, '3.18.1', {"requires": ["handlebars-base"]});