handlebars-source 1.0.12 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handlebars-source might be problematic. Click here for more details.

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