Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80684 views
1
/*!
2
3
handlebars v3.0.0
4
5
Copyright (C) 2011-2014 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
/* exported Handlebars */
28
(function (root, factory) {
29
if (typeof define === 'function' && define.amd) {
30
define([], factory);
31
} else if (typeof exports === 'object') {
32
module.exports = factory();
33
} else {
34
root.Handlebars = factory();
35
}
36
}(this, function () {
37
// handlebars/utils.js
38
var __module3__ = (function() {
39
"use strict";
40
var __exports__ = {};
41
/*jshint -W004 */
42
var escape = {
43
"&": "&",
44
"<": "&lt;",
45
">": "&gt;",
46
'"': "&quot;",
47
"'": "&#x27;",
48
"`": "&#x60;"
49
};
50
51
var badChars = /[&<>"'`]/g;
52
var possible = /[&<>"'`]/;
53
54
function escapeChar(chr) {
55
return escape[chr];
56
}
57
58
function extend(obj /* , ...source */) {
59
for (var i = 1; i < arguments.length; i++) {
60
for (var key in arguments[i]) {
61
if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
62
obj[key] = arguments[i][key];
63
}
64
}
65
}
66
67
return obj;
68
}
69
70
__exports__.extend = extend;var toString = Object.prototype.toString;
71
__exports__.toString = toString;
72
// Sourced from lodash
73
// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
74
var isFunction = function(value) {
75
return typeof value === 'function';
76
};
77
// fallback for older versions of Chrome and Safari
78
/* istanbul ignore next */
79
if (isFunction(/x/)) {
80
isFunction = function(value) {
81
return typeof value === 'function' && toString.call(value) === '[object Function]';
82
};
83
}
84
var isFunction;
85
__exports__.isFunction = isFunction;
86
/* istanbul ignore next */
87
var isArray = Array.isArray || function(value) {
88
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
89
};
90
__exports__.isArray = isArray;
91
// Older IE versions do not directly support indexOf so we must implement our own, sadly.
92
function indexOf(array, value) {
93
for (var i = 0, len = array.length; i < len; i++) {
94
if (array[i] === value) {
95
return i;
96
}
97
}
98
return -1;
99
}
100
101
__exports__.indexOf = indexOf;
102
function escapeExpression(string) {
103
// don't escape SafeStrings, since they're already safe
104
if (string && string.toHTML) {
105
return string.toHTML();
106
} else if (string == null) {
107
return "";
108
} else if (!string) {
109
return string + '';
110
}
111
112
// Force a string conversion as this will be done by the append regardless and
113
// the regex test will do this transparently behind the scenes, causing issues if
114
// an object's to string has escaped characters in it.
115
string = "" + string;
116
117
if(!possible.test(string)) { return string; }
118
return string.replace(badChars, escapeChar);
119
}
120
121
__exports__.escapeExpression = escapeExpression;function isEmpty(value) {
122
if (!value && value !== 0) {
123
return true;
124
} else if (isArray(value) && value.length === 0) {
125
return true;
126
} else {
127
return false;
128
}
129
}
130
131
__exports__.isEmpty = isEmpty;function blockParams(params, ids) {
132
params.path = ids;
133
return params;
134
}
135
136
__exports__.blockParams = blockParams;function appendContextPath(contextPath, id) {
137
return (contextPath ? contextPath + '.' : '') + id;
138
}
139
140
__exports__.appendContextPath = appendContextPath;
141
return __exports__;
142
})();
143
144
// handlebars/exception.js
145
var __module4__ = (function() {
146
"use strict";
147
var __exports__;
148
149
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
150
151
function Exception(message, node) {
152
var loc = node && node.loc,
153
line,
154
column;
155
if (loc) {
156
line = loc.start.line;
157
column = loc.start.column;
158
159
message += ' - ' + line + ':' + column;
160
}
161
162
var tmp = Error.prototype.constructor.call(this, message);
163
164
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
165
for (var idx = 0; idx < errorProps.length; idx++) {
166
this[errorProps[idx]] = tmp[errorProps[idx]];
167
}
168
169
if (loc) {
170
this.lineNumber = line;
171
this.column = column;
172
}
173
}
174
175
Exception.prototype = new Error();
176
177
__exports__ = Exception;
178
return __exports__;
179
})();
180
181
// handlebars/base.js
182
var __module2__ = (function(__dependency1__, __dependency2__) {
183
"use strict";
184
var __exports__ = {};
185
var Utils = __dependency1__;
186
var Exception = __dependency2__;
187
188
var VERSION = "3.0.0";
189
__exports__.VERSION = VERSION;var COMPILER_REVISION = 6;
190
__exports__.COMPILER_REVISION = COMPILER_REVISION;
191
var REVISION_CHANGES = {
192
1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
193
2: '== 1.0.0-rc.3',
194
3: '== 1.0.0-rc.4',
195
4: '== 1.x.x',
196
5: '== 2.0.0-alpha.x',
197
6: '>= 2.0.0-beta.1'
198
};
199
__exports__.REVISION_CHANGES = REVISION_CHANGES;
200
var isArray = Utils.isArray,
201
isFunction = Utils.isFunction,
202
toString = Utils.toString,
203
objectType = '[object Object]';
204
205
function HandlebarsEnvironment(helpers, partials) {
206
this.helpers = helpers || {};
207
this.partials = partials || {};
208
209
registerDefaultHelpers(this);
210
}
211
212
__exports__.HandlebarsEnvironment = HandlebarsEnvironment;HandlebarsEnvironment.prototype = {
213
constructor: HandlebarsEnvironment,
214
215
logger: logger,
216
log: log,
217
218
registerHelper: function(name, fn) {
219
if (toString.call(name) === objectType) {
220
if (fn) { throw new Exception('Arg not supported with multiple helpers'); }
221
Utils.extend(this.helpers, name);
222
} else {
223
this.helpers[name] = fn;
224
}
225
},
226
unregisterHelper: function(name) {
227
delete this.helpers[name];
228
},
229
230
registerPartial: function(name, partial) {
231
if (toString.call(name) === objectType) {
232
Utils.extend(this.partials, name);
233
} else {
234
if (typeof partial === 'undefined') {
235
throw new Exception('Attempting to register a partial as undefined');
236
}
237
this.partials[name] = partial;
238
}
239
},
240
unregisterPartial: function(name) {
241
delete this.partials[name];
242
}
243
};
244
245
function registerDefaultHelpers(instance) {
246
instance.registerHelper('helperMissing', function(/* [args, ]options */) {
247
if(arguments.length === 1) {
248
// A missing field in a {{foo}} constuct.
249
return undefined;
250
} else {
251
// Someone is actually trying to call something, blow up.
252
throw new Exception("Missing helper: '" + arguments[arguments.length-1].name + "'");
253
}
254
});
255
256
instance.registerHelper('blockHelperMissing', function(context, options) {
257
var inverse = options.inverse,
258
fn = options.fn;
259
260
if(context === true) {
261
return fn(this);
262
} else if(context === false || context == null) {
263
return inverse(this);
264
} else if (isArray(context)) {
265
if(context.length > 0) {
266
if (options.ids) {
267
options.ids = [options.name];
268
}
269
270
return instance.helpers.each(context, options);
271
} else {
272
return inverse(this);
273
}
274
} else {
275
if (options.data && options.ids) {
276
var data = createFrame(options.data);
277
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.name);
278
options = {data: data};
279
}
280
281
return fn(context, options);
282
}
283
});
284
285
instance.registerHelper('each', function(context, options) {
286
if (!options) {
287
throw new Exception('Must pass iterator to #each');
288
}
289
290
var fn = options.fn, inverse = options.inverse;
291
var i = 0, ret = "", data;
292
293
var contextPath;
294
if (options.data && options.ids) {
295
contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.';
296
}
297
298
if (isFunction(context)) { context = context.call(this); }
299
300
if (options.data) {
301
data = createFrame(options.data);
302
}
303
304
function execIteration(key, i, last) {
305
if (data) {
306
data.key = key;
307
data.index = i;
308
data.first = i === 0;
309
data.last = !!last;
310
311
if (contextPath) {
312
data.contextPath = contextPath + key;
313
}
314
}
315
316
ret = ret + fn(context[key], {
317
data: data,
318
blockParams: Utils.blockParams([context[key], key], [contextPath + key, null])
319
});
320
}
321
322
if(context && typeof context === 'object') {
323
if (isArray(context)) {
324
for(var j = context.length; i<j; i++) {
325
execIteration(i, i, i === context.length-1);
326
}
327
} else {
328
var priorKey;
329
330
for(var key in context) {
331
if(context.hasOwnProperty(key)) {
332
// We're running the iterations one step out of sync so we can detect
333
// the last iteration without have to scan the object twice and create
334
// an itermediate keys array.
335
if (priorKey) {
336
execIteration(priorKey, i-1);
337
}
338
priorKey = key;
339
i++;
340
}
341
}
342
if (priorKey) {
343
execIteration(priorKey, i-1, true);
344
}
345
}
346
}
347
348
if(i === 0){
349
ret = inverse(this);
350
}
351
352
return ret;
353
});
354
355
instance.registerHelper('if', function(conditional, options) {
356
if (isFunction(conditional)) { conditional = conditional.call(this); }
357
358
// Default behavior is to render the positive path if the value is truthy and not empty.
359
// The `includeZero` option may be set to treat the condtional as purely not empty based on the
360
// behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative.
361
if ((!options.hash.includeZero && !conditional) || Utils.isEmpty(conditional)) {
362
return options.inverse(this);
363
} else {
364
return options.fn(this);
365
}
366
});
367
368
instance.registerHelper('unless', function(conditional, options) {
369
return instance.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn, hash: options.hash});
370
});
371
372
instance.registerHelper('with', function(context, options) {
373
if (isFunction(context)) { context = context.call(this); }
374
375
var fn = options.fn;
376
377
if (!Utils.isEmpty(context)) {
378
if (options.data && options.ids) {
379
var data = createFrame(options.data);
380
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]);
381
options = {data:data};
382
}
383
384
return fn(context, options);
385
} else {
386
return options.inverse(this);
387
}
388
});
389
390
instance.registerHelper('log', function(message, options) {
391
var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
392
instance.log(level, message);
393
});
394
395
instance.registerHelper('lookup', function(obj, field) {
396
return obj && obj[field];
397
});
398
}
399
400
var logger = {
401
methodMap: { 0: 'debug', 1: 'info', 2: 'warn', 3: 'error' },
402
403
// State enum
404
DEBUG: 0,
405
INFO: 1,
406
WARN: 2,
407
ERROR: 3,
408
level: 1,
409
410
// Can be overridden in the host environment
411
log: function(level, message) {
412
if (typeof console !== 'undefined' && logger.level <= level) {
413
var method = logger.methodMap[level];
414
(console[method] || console.log).call(console, message);
415
}
416
}
417
};
418
__exports__.logger = logger;
419
var log = logger.log;
420
__exports__.log = log;
421
var createFrame = function(object) {
422
var frame = Utils.extend({}, object);
423
frame._parent = object;
424
return frame;
425
};
426
__exports__.createFrame = createFrame;
427
return __exports__;
428
})(__module3__, __module4__);
429
430
// handlebars/safe-string.js
431
var __module5__ = (function() {
432
"use strict";
433
var __exports__;
434
// Build out our basic SafeString type
435
function SafeString(string) {
436
this.string = string;
437
}
438
439
SafeString.prototype.toString = SafeString.prototype.toHTML = function() {
440
return "" + this.string;
441
};
442
443
__exports__ = SafeString;
444
return __exports__;
445
})();
446
447
// handlebars/runtime.js
448
var __module6__ = (function(__dependency1__, __dependency2__, __dependency3__) {
449
"use strict";
450
var __exports__ = {};
451
var Utils = __dependency1__;
452
var Exception = __dependency2__;
453
var COMPILER_REVISION = __dependency3__.COMPILER_REVISION;
454
var REVISION_CHANGES = __dependency3__.REVISION_CHANGES;
455
var createFrame = __dependency3__.createFrame;
456
457
function checkRevision(compilerInfo) {
458
var compilerRevision = compilerInfo && compilerInfo[0] || 1,
459
currentRevision = COMPILER_REVISION;
460
461
if (compilerRevision !== currentRevision) {
462
if (compilerRevision < currentRevision) {
463
var runtimeVersions = REVISION_CHANGES[currentRevision],
464
compilerVersions = REVISION_CHANGES[compilerRevision];
465
throw new Exception("Template was precompiled with an older version of Handlebars than the current runtime. "+
466
"Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+").");
467
} else {
468
// Use the embedded version info since the runtime doesn't know about this revision yet
469
throw new Exception("Template was precompiled with a newer version of Handlebars than the current runtime. "+
470
"Please update your runtime to a newer version ("+compilerInfo[1]+").");
471
}
472
}
473
}
474
475
__exports__.checkRevision = checkRevision;// TODO: Remove this line and break up compilePartial
476
477
function template(templateSpec, env) {
478
/* istanbul ignore next */
479
if (!env) {
480
throw new Exception("No environment passed to template");
481
}
482
if (!templateSpec || !templateSpec.main) {
483
throw new Exception('Unknown template object: ' + typeof templateSpec);
484
}
485
486
// Note: Using env.VM references rather than local var references throughout this section to allow
487
// for external users to override these as psuedo-supported APIs.
488
env.VM.checkRevision(templateSpec.compiler);
489
490
var invokePartialWrapper = function(partial, context, options) {
491
if (options.hash) {
492
context = Utils.extend({}, context, options.hash);
493
}
494
495
partial = env.VM.resolvePartial.call(this, partial, context, options);
496
var result = env.VM.invokePartial.call(this, partial, context, options);
497
498
if (result == null && env.compile) {
499
options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env);
500
result = options.partials[options.name](context, options);
501
}
502
if (result != null) {
503
if (options.indent) {
504
var lines = result.split('\n');
505
for (var i = 0, l = lines.length; i < l; i++) {
506
if (!lines[i] && i + 1 === l) {
507
break;
508
}
509
510
lines[i] = options.indent + lines[i];
511
}
512
result = lines.join('\n');
513
}
514
return result;
515
} else {
516
throw new Exception("The partial " + options.name + " could not be compiled when running in runtime-only mode");
517
}
518
};
519
520
// Just add water
521
var container = {
522
strict: function(obj, name) {
523
if (!(name in obj)) {
524
throw new Exception('"' + name + '" not defined in ' + obj);
525
}
526
return obj[name];
527
},
528
lookup: function(depths, name) {
529
var len = depths.length;
530
for (var i = 0; i < len; i++) {
531
if (depths[i] && depths[i][name] != null) {
532
return depths[i][name];
533
}
534
}
535
},
536
lambda: function(current, context) {
537
return typeof current === 'function' ? current.call(context) : current;
538
},
539
540
escapeExpression: Utils.escapeExpression,
541
invokePartial: invokePartialWrapper,
542
543
fn: function(i) {
544
return templateSpec[i];
545
},
546
547
programs: [],
548
program: function(i, data, declaredBlockParams, blockParams, depths) {
549
var programWrapper = this.programs[i],
550
fn = this.fn(i);
551
if (data || depths || blockParams || declaredBlockParams) {
552
programWrapper = program(this, i, fn, data, declaredBlockParams, blockParams, depths);
553
} else if (!programWrapper) {
554
programWrapper = this.programs[i] = program(this, i, fn);
555
}
556
return programWrapper;
557
},
558
559
data: function(data, depth) {
560
while (data && depth--) {
561
data = data._parent;
562
}
563
return data;
564
},
565
merge: function(param, common) {
566
var ret = param || common;
567
568
if (param && common && (param !== common)) {
569
ret = Utils.extend({}, common, param);
570
}
571
572
return ret;
573
},
574
575
noop: env.VM.noop,
576
compilerInfo: templateSpec.compiler
577
};
578
579
var ret = function(context, options) {
580
options = options || {};
581
var data = options.data;
582
583
ret._setup(options);
584
if (!options.partial && templateSpec.useData) {
585
data = initData(context, data);
586
}
587
var depths,
588
blockParams = templateSpec.useBlockParams ? [] : undefined;
589
if (templateSpec.useDepths) {
590
depths = options.depths ? [context].concat(options.depths) : [context];
591
}
592
593
return templateSpec.main.call(container, context, container.helpers, container.partials, data, blockParams, depths);
594
};
595
ret.isTop = true;
596
597
ret._setup = function(options) {
598
if (!options.partial) {
599
container.helpers = container.merge(options.helpers, env.helpers);
600
601
if (templateSpec.usePartial) {
602
container.partials = container.merge(options.partials, env.partials);
603
}
604
} else {
605
container.helpers = options.helpers;
606
container.partials = options.partials;
607
}
608
};
609
610
ret._child = function(i, data, blockParams, depths) {
611
if (templateSpec.useBlockParams && !blockParams) {
612
throw new Exception('must pass block params');
613
}
614
if (templateSpec.useDepths && !depths) {
615
throw new Exception('must pass parent depths');
616
}
617
618
return program(container, i, templateSpec[i], data, 0, blockParams, depths);
619
};
620
return ret;
621
}
622
623
__exports__.template = template;function program(container, i, fn, data, declaredBlockParams, blockParams, depths) {
624
var prog = function(context, options) {
625
options = options || {};
626
627
return fn.call(container,
628
context,
629
container.helpers, container.partials,
630
options.data || data,
631
blockParams && [options.blockParams].concat(blockParams),
632
depths && [context].concat(depths));
633
};
634
prog.program = i;
635
prog.depth = depths ? depths.length : 0;
636
prog.blockParams = declaredBlockParams || 0;
637
return prog;
638
}
639
640
__exports__.program = program;function resolvePartial(partial, context, options) {
641
if (!partial) {
642
partial = options.partials[options.name];
643
} else if (!partial.call && !options.name) {
644
// This is a dynamic partial that returned a string
645
options.name = partial;
646
partial = options.partials[partial];
647
}
648
return partial;
649
}
650
651
__exports__.resolvePartial = resolvePartial;function invokePartial(partial, context, options) {
652
options.partial = true;
653
654
if(partial === undefined) {
655
throw new Exception("The partial " + options.name + " could not be found");
656
} else if(partial instanceof Function) {
657
return partial(context, options);
658
}
659
}
660
661
__exports__.invokePartial = invokePartial;function noop() { return ""; }
662
663
__exports__.noop = noop;function initData(context, data) {
664
if (!data || !('root' in data)) {
665
data = data ? createFrame(data) : {};
666
data.root = context;
667
}
668
return data;
669
}
670
return __exports__;
671
})(__module3__, __module4__, __module2__);
672
673
// handlebars.runtime.js
674
var __module1__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {
675
"use strict";
676
var __exports__;
677
/*globals Handlebars: true */
678
var base = __dependency1__;
679
680
// Each of these augment the Handlebars object. No need to setup here.
681
// (This is done to easily share code between commonjs and browse envs)
682
var SafeString = __dependency2__;
683
var Exception = __dependency3__;
684
var Utils = __dependency4__;
685
var runtime = __dependency5__;
686
687
// For compatibility and usage outside of module systems, make the Handlebars object a namespace
688
var create = function() {
689
var hb = new base.HandlebarsEnvironment();
690
691
Utils.extend(hb, base);
692
hb.SafeString = SafeString;
693
hb.Exception = Exception;
694
hb.Utils = Utils;
695
hb.escapeExpression = Utils.escapeExpression;
696
697
hb.VM = runtime;
698
hb.template = function(spec) {
699
return runtime.template(spec, hb);
700
};
701
702
return hb;
703
};
704
705
var Handlebars = create();
706
Handlebars.create = create;
707
708
/*jshint -W040 */
709
/* istanbul ignore next */
710
var root = typeof global !== 'undefined' ? global : window,
711
$Handlebars = root.Handlebars;
712
/* istanbul ignore next */
713
Handlebars.noConflict = function() {
714
if (root.Handlebars === Handlebars) {
715
root.Handlebars = $Handlebars;
716
}
717
};
718
719
Handlebars['default'] = Handlebars;
720
721
__exports__ = Handlebars;
722
return __exports__;
723
})(__module2__, __module5__, __module4__, __module3__, __module6__);
724
725
// handlebars/compiler/ast.js
726
var __module7__ = (function() {
727
"use strict";
728
var __exports__;
729
var AST = {
730
Program: function(statements, blockParams, strip, locInfo) {
731
this.loc = locInfo;
732
this.type = 'Program';
733
this.body = statements;
734
735
this.blockParams = blockParams;
736
this.strip = strip;
737
},
738
739
MustacheStatement: function(path, params, hash, escaped, strip, locInfo) {
740
this.loc = locInfo;
741
this.type = 'MustacheStatement';
742
743
this.path = path;
744
this.params = params || [];
745
this.hash = hash;
746
this.escaped = escaped;
747
748
this.strip = strip;
749
},
750
751
BlockStatement: function(path, params, hash, program, inverse, openStrip, inverseStrip, closeStrip, locInfo) {
752
this.loc = locInfo;
753
this.type = 'BlockStatement';
754
755
this.path = path;
756
this.params = params || [];
757
this.hash = hash;
758
this.program = program;
759
this.inverse = inverse;
760
761
this.openStrip = openStrip;
762
this.inverseStrip = inverseStrip;
763
this.closeStrip = closeStrip;
764
},
765
766
PartialStatement: function(name, params, hash, strip, locInfo) {
767
this.loc = locInfo;
768
this.type = 'PartialStatement';
769
770
this.name = name;
771
this.params = params || [];
772
this.hash = hash;
773
774
this.indent = '';
775
this.strip = strip;
776
},
777
778
ContentStatement: function(string, locInfo) {
779
this.loc = locInfo;
780
this.type = 'ContentStatement';
781
this.original = this.value = string;
782
},
783
784
CommentStatement: function(comment, strip, locInfo) {
785
this.loc = locInfo;
786
this.type = 'CommentStatement';
787
this.value = comment;
788
789
this.strip = strip;
790
},
791
792
SubExpression: function(path, params, hash, locInfo) {
793
this.loc = locInfo;
794
795
this.type = 'SubExpression';
796
this.path = path;
797
this.params = params || [];
798
this.hash = hash;
799
},
800
801
PathExpression: function(data, depth, parts, original, locInfo) {
802
this.loc = locInfo;
803
this.type = 'PathExpression';
804
805
this.data = data;
806
this.original = original;
807
this.parts = parts;
808
this.depth = depth;
809
},
810
811
StringLiteral: function(string, locInfo) {
812
this.loc = locInfo;
813
this.type = 'StringLiteral';
814
this.original =
815
this.value = string;
816
},
817
818
NumberLiteral: function(number, locInfo) {
819
this.loc = locInfo;
820
this.type = 'NumberLiteral';
821
this.original =
822
this.value = Number(number);
823
},
824
825
BooleanLiteral: function(bool, locInfo) {
826
this.loc = locInfo;
827
this.type = 'BooleanLiteral';
828
this.original =
829
this.value = bool === 'true';
830
},
831
832
Hash: function(pairs, locInfo) {
833
this.loc = locInfo;
834
this.type = 'Hash';
835
this.pairs = pairs;
836
},
837
HashPair: function(key, value, locInfo) {
838
this.loc = locInfo;
839
this.type = 'HashPair';
840
this.key = key;
841
this.value = value;
842
},
843
844
// Public API used to evaluate derived attributes regarding AST nodes
845
helpers: {
846
// a mustache is definitely a helper if:
847
// * it is an eligible helper, and
848
// * it has at least one parameter or hash segment
849
// TODO: Make these public utility methods
850
helperExpression: function(node) {
851
return !!(node.type === 'SubExpression' || node.params.length || node.hash);
852
},
853
854
scopedId: function(path) {
855
return (/^\.|this\b/).test(path.original);
856
},
857
858
// an ID is simple if it only has one part, and that part is not
859
// `..` or `this`.
860
simpleId: function(path) {
861
return path.parts.length === 1 && !AST.helpers.scopedId(path) && !path.depth;
862
}
863
}
864
};
865
866
867
// Must be exported as an object rather than the root of the module as the jison lexer
868
// must modify the object to operate properly.
869
__exports__ = AST;
870
return __exports__;
871
})();
872
873
// handlebars/compiler/parser.js
874
var __module9__ = (function() {
875
"use strict";
876
var __exports__;
877
/* jshint ignore:start */
878
/* istanbul ignore next */
879
/* Jison generated parser */
880
var handlebars = (function(){
881
var parser = {trace: function trace() { },
882
yy: {},
883
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,"CONTENT":14,"openRawBlock":15,"END_RAW_BLOCK":16,"OPEN_RAW_BLOCK":17,"helperName":18,"openRawBlock_repetition0":19,"openRawBlock_option0":20,"CLOSE_RAW_BLOCK":21,"openBlock":22,"block_option0":23,"closeBlock":24,"openInverse":25,"block_option1":26,"OPEN_BLOCK":27,"openBlock_repetition0":28,"openBlock_option0":29,"openBlock_option1":30,"CLOSE":31,"OPEN_INVERSE":32,"openInverse_repetition0":33,"openInverse_option0":34,"openInverse_option1":35,"openInverseChain":36,"OPEN_INVERSE_CHAIN":37,"openInverseChain_repetition0":38,"openInverseChain_option0":39,"openInverseChain_option1":40,"inverseAndProgram":41,"INVERSE":42,"inverseChain":43,"inverseChain_option0":44,"OPEN_ENDBLOCK":45,"OPEN":46,"mustache_repetition0":47,"mustache_option0":48,"OPEN_UNESCAPED":49,"mustache_repetition1":50,"mustache_option1":51,"CLOSE_UNESCAPED":52,"OPEN_PARTIAL":53,"partialName":54,"partial_repetition0":55,"partial_option0":56,"param":57,"sexpr":58,"OPEN_SEXPR":59,"sexpr_repetition0":60,"sexpr_option0":61,"CLOSE_SEXPR":62,"hash":63,"hash_repetition_plus0":64,"hashSegment":65,"ID":66,"EQUALS":67,"blockParams":68,"OPEN_BLOCK_PARAMS":69,"blockParams_repetition_plus0":70,"CLOSE_BLOCK_PARAMS":71,"path":72,"dataName":73,"STRING":74,"NUMBER":75,"BOOLEAN":76,"DATA":77,"pathSegments":78,"SEP":79,"$accept":0,"$end":1},
884
terminals_: {2:"error",5:"EOF",13:"COMMENT",14:"CONTENT",16:"END_RAW_BLOCK",17:"OPEN_RAW_BLOCK",21:"CLOSE_RAW_BLOCK",27:"OPEN_BLOCK",31:"CLOSE",32:"OPEN_INVERSE",37:"OPEN_INVERSE_CHAIN",42:"INVERSE",45:"OPEN_ENDBLOCK",46:"OPEN",49:"OPEN_UNESCAPED",52:"CLOSE_UNESCAPED",53:"OPEN_PARTIAL",59:"OPEN_SEXPR",62:"CLOSE_SEXPR",66:"ID",67:"EQUALS",69:"OPEN_BLOCK_PARAMS",71:"CLOSE_BLOCK_PARAMS",74:"STRING",75:"NUMBER",76:"BOOLEAN",77:"DATA",79:"SEP"},
885
productions_: [0,[3,2],[4,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[12,1],[10,3],[15,5],[9,4],[9,4],[22,6],[25,6],[36,6],[41,2],[43,3],[43,1],[24,3],[8,5],[8,5],[11,5],[57,1],[57,1],[58,5],[63,1],[65,3],[68,3],[18,1],[18,1],[18,1],[18,1],[18,1],[54,1],[54,1],[73,2],[72,1],[78,3],[78,1],[6,0],[6,2],[19,0],[19,2],[20,0],[20,1],[23,0],[23,1],[26,0],[26,1],[28,0],[28,2],[29,0],[29,1],[30,0],[30,1],[33,0],[33,2],[34,0],[34,1],[35,0],[35,1],[38,0],[38,2],[39,0],[39,1],[40,0],[40,1],[44,0],[44,1],[47,0],[47,2],[48,0],[48,1],[50,0],[50,2],[51,0],[51,1],[55,0],[55,2],[56,0],[56,1],[60,0],[60,2],[61,0],[61,1],[64,1],[64,2],[70,1],[70,2]],
886
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
887
888
var $0 = $$.length - 1;
889
switch (yystate) {
890
case 1: return $$[$0-1];
891
break;
892
case 2:this.$ = new yy.Program($$[$0], null, {}, yy.locInfo(this._$));
893
break;
894
case 3:this.$ = $$[$0];
895
break;
896
case 4:this.$ = $$[$0];
897
break;
898
case 5:this.$ = $$[$0];
899
break;
900
case 6:this.$ = $$[$0];
901
break;
902
case 7:this.$ = $$[$0];
903
break;
904
case 8:this.$ = new yy.CommentStatement(yy.stripComment($$[$0]), yy.stripFlags($$[$0], $$[$0]), yy.locInfo(this._$));
905
break;
906
case 9:this.$ = new yy.ContentStatement($$[$0], yy.locInfo(this._$));
907
break;
908
case 10:this.$ = yy.prepareRawBlock($$[$0-2], $$[$0-1], $$[$0], this._$);
909
break;
910
case 11:this.$ = { path: $$[$0-3], params: $$[$0-2], hash: $$[$0-1] };
911
break;
912
case 12:this.$ = yy.prepareBlock($$[$0-3], $$[$0-2], $$[$0-1], $$[$0], false, this._$);
913
break;
914
case 13:this.$ = yy.prepareBlock($$[$0-3], $$[$0-2], $$[$0-1], $$[$0], true, this._$);
915
break;
916
case 14:this.$ = { path: $$[$0-4], params: $$[$0-3], hash: $$[$0-2], blockParams: $$[$0-1], strip: yy.stripFlags($$[$0-5], $$[$0]) };
917
break;
918
case 15:this.$ = { path: $$[$0-4], params: $$[$0-3], hash: $$[$0-2], blockParams: $$[$0-1], strip: yy.stripFlags($$[$0-5], $$[$0]) };
919
break;
920
case 16:this.$ = { path: $$[$0-4], params: $$[$0-3], hash: $$[$0-2], blockParams: $$[$0-1], strip: yy.stripFlags($$[$0-5], $$[$0]) };
921
break;
922
case 17:this.$ = { strip: yy.stripFlags($$[$0-1], $$[$0-1]), program: $$[$0] };
923
break;
924
case 18:
925
var inverse = yy.prepareBlock($$[$0-2], $$[$0-1], $$[$0], $$[$0], false, this._$),
926
program = new yy.Program([inverse], null, {}, yy.locInfo(this._$));
927
program.chained = true;
928
929
this.$ = { strip: $$[$0-2].strip, program: program, chain: true };
930
931
break;
932
case 19:this.$ = $$[$0];
933
break;
934
case 20:this.$ = {path: $$[$0-1], strip: yy.stripFlags($$[$0-2], $$[$0])};
935
break;
936
case 21:this.$ = yy.prepareMustache($$[$0-3], $$[$0-2], $$[$0-1], $$[$0-4], yy.stripFlags($$[$0-4], $$[$0]), this._$);
937
break;
938
case 22:this.$ = yy.prepareMustache($$[$0-3], $$[$0-2], $$[$0-1], $$[$0-4], yy.stripFlags($$[$0-4], $$[$0]), this._$);
939
break;
940
case 23:this.$ = new yy.PartialStatement($$[$0-3], $$[$0-2], $$[$0-1], yy.stripFlags($$[$0-4], $$[$0]), yy.locInfo(this._$));
941
break;
942
case 24:this.$ = $$[$0];
943
break;
944
case 25:this.$ = $$[$0];
945
break;
946
case 26:this.$ = new yy.SubExpression($$[$0-3], $$[$0-2], $$[$0-1], yy.locInfo(this._$));
947
break;
948
case 27:this.$ = new yy.Hash($$[$0], yy.locInfo(this._$));
949
break;
950
case 28:this.$ = new yy.HashPair($$[$0-2], $$[$0], yy.locInfo(this._$));
951
break;
952
case 29:this.$ = $$[$0-1];
953
break;
954
case 30:this.$ = $$[$0];
955
break;
956
case 31:this.$ = $$[$0];
957
break;
958
case 32:this.$ = new yy.StringLiteral($$[$0], yy.locInfo(this._$));
959
break;
960
case 33:this.$ = new yy.NumberLiteral($$[$0], yy.locInfo(this._$));
961
break;
962
case 34:this.$ = new yy.BooleanLiteral($$[$0], yy.locInfo(this._$));
963
break;
964
case 35:this.$ = $$[$0];
965
break;
966
case 36:this.$ = $$[$0];
967
break;
968
case 37:this.$ = yy.preparePath(true, $$[$0], this._$);
969
break;
970
case 38:this.$ = yy.preparePath(false, $$[$0], this._$);
971
break;
972
case 39: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2];
973
break;
974
case 40:this.$ = [{part: $$[$0]}];
975
break;
976
case 41:this.$ = [];
977
break;
978
case 42:$$[$0-1].push($$[$0]);
979
break;
980
case 43:this.$ = [];
981
break;
982
case 44:$$[$0-1].push($$[$0]);
983
break;
984
case 51:this.$ = [];
985
break;
986
case 52:$$[$0-1].push($$[$0]);
987
break;
988
case 57:this.$ = [];
989
break;
990
case 58:$$[$0-1].push($$[$0]);
991
break;
992
case 63:this.$ = [];
993
break;
994
case 64:$$[$0-1].push($$[$0]);
995
break;
996
case 71:this.$ = [];
997
break;
998
case 72:$$[$0-1].push($$[$0]);
999
break;
1000
case 75:this.$ = [];
1001
break;
1002
case 76:$$[$0-1].push($$[$0]);
1003
break;
1004
case 79:this.$ = [];
1005
break;
1006
case 80:$$[$0-1].push($$[$0]);
1007
break;
1008
case 83:this.$ = [];
1009
break;
1010
case 84:$$[$0-1].push($$[$0]);
1011
break;
1012
case 87:this.$ = [$$[$0]];
1013
break;
1014
case 88:$$[$0-1].push($$[$0]);
1015
break;
1016
case 89:this.$ = [$$[$0]];
1017
break;
1018
case 90:$$[$0-1].push($$[$0]);
1019
break;
1020
}
1021
},
1022
table: [{3:1,4:2,5:[2,41],6:3,13:[2,41],14:[2,41],17:[2,41],27:[2,41],32:[2,41],46:[2,41],49:[2,41],53:[2,41]},{1:[3]},{5:[1,4]},{5:[2,2],7:5,8:6,9:7,10:8,11:9,12:10,13:[1,11],14:[1,18],15:16,17:[1,21],22:14,25:15,27:[1,19],32:[1,20],37:[2,2],42:[2,2],45:[2,2],46:[1,12],49:[1,13],53:[1,17]},{1:[2,1]},{5:[2,42],13:[2,42],14:[2,42],17:[2,42],27:[2,42],32:[2,42],37:[2,42],42:[2,42],45:[2,42],46:[2,42],49:[2,42],53:[2,42]},{5:[2,3],13:[2,3],14:[2,3],17:[2,3],27:[2,3],32:[2,3],37:[2,3],42:[2,3],45:[2,3],46:[2,3],49:[2,3],53:[2,3]},{5:[2,4],13:[2,4],14:[2,4],17:[2,4],27:[2,4],32:[2,4],37:[2,4],42:[2,4],45:[2,4],46:[2,4],49:[2,4],53:[2,4]},{5:[2,5],13:[2,5],14:[2,5],17:[2,5],27:[2,5],32:[2,5],37:[2,5],42:[2,5],45:[2,5],46:[2,5],49:[2,5],53:[2,5]},{5:[2,6],13:[2,6],14:[2,6],17:[2,6],27:[2,6],32:[2,6],37:[2,6],42:[2,6],45:[2,6],46:[2,6],49:[2,6],53:[2,6]},{5:[2,7],13:[2,7],14:[2,7],17:[2,7],27:[2,7],32:[2,7],37:[2,7],42:[2,7],45:[2,7],46:[2,7],49:[2,7],53:[2,7]},{5:[2,8],13:[2,8],14:[2,8],17:[2,8],27:[2,8],32:[2,8],37:[2,8],42:[2,8],45:[2,8],46:[2,8],49:[2,8],53:[2,8]},{18:22,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{18:31,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{4:32,6:3,13:[2,41],14:[2,41],17:[2,41],27:[2,41],32:[2,41],37:[2,41],42:[2,41],45:[2,41],46:[2,41],49:[2,41],53:[2,41]},{4:33,6:3,13:[2,41],14:[2,41],17:[2,41],27:[2,41],32:[2,41],42:[2,41],45:[2,41],46:[2,41],49:[2,41],53:[2,41]},{12:34,14:[1,18]},{18:36,54:35,58:37,59:[1,38],66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{5:[2,9],13:[2,9],14:[2,9],16:[2,9],17:[2,9],27:[2,9],32:[2,9],37:[2,9],42:[2,9],45:[2,9],46:[2,9],49:[2,9],53:[2,9]},{18:39,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{18:40,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{18:41,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{31:[2,71],47:42,59:[2,71],66:[2,71],74:[2,71],75:[2,71],76:[2,71],77:[2,71]},{21:[2,30],31:[2,30],52:[2,30],59:[2,30],62:[2,30],66:[2,30],69:[2,30],74:[2,30],75:[2,30],76:[2,30],77:[2,30]},{21:[2,31],31:[2,31],52:[2,31],59:[2,31],62:[2,31],66:[2,31],69:[2,31],74:[2,31],75:[2,31],76:[2,31],77:[2,31]},{21:[2,32],31:[2,32],52:[2,32],59:[2,32],62:[2,32],66:[2,32],69:[2,32],74:[2,32],75:[2,32],76:[2,32],77:[2,32]},{21:[2,33],31:[2,33],52:[2,33],59:[2,33],62:[2,33],66:[2,33],69:[2,33],74:[2,33],75:[2,33],76:[2,33],77:[2,33]},{21:[2,34],31:[2,34],52:[2,34],59:[2,34],62:[2,34],66:[2,34],69:[2,34],74:[2,34],75:[2,34],76:[2,34],77:[2,34]},{21:[2,38],31:[2,38],52:[2,38],59:[2,38],62:[2,38],66:[2,38],69:[2,38],74:[2,38],75:[2,38],76:[2,38],77:[2,38],79:[1,43]},{66:[1,30],78:44},{21:[2,40],31:[2,40],52:[2,40],59:[2,40],62:[2,40],66:[2,40],69:[2,40],74:[2,40],75:[2,40],76:[2,40],77:[2,40],79:[2,40]},{50:45,52:[2,75],59:[2,75],66:[2,75],74:[2,75],75:[2,75],76:[2,75],77:[2,75]},{23:46,36:48,37:[1,50],41:49,42:[1,51],43:47,45:[2,47]},{26:52,41:53,42:[1,51],45:[2,49]},{16:[1,54]},{31:[2,79],55:55,59:[2,79],66:[2,79],74:[2,79],75:[2,79],76:[2,79],77:[2,79]},{31:[2,35],59:[2,35],66:[2,35],74:[2,35],75:[2,35],76:[2,35],77:[2,35]},{31:[2,36],59:[2,36],66:[2,36],74:[2,36],75:[2,36],76:[2,36],77:[2,36]},{18:56,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{28:57,31:[2,51],59:[2,51],66:[2,51],69:[2,51],74:[2,51],75:[2,51],76:[2,51],77:[2,51]},{31:[2,57],33:58,59:[2,57],66:[2,57],69:[2,57],74:[2,57],75:[2,57],76:[2,57],77:[2,57]},{19:59,21:[2,43],59:[2,43],66:[2,43],74:[2,43],75:[2,43],76:[2,43],77:[2,43]},{18:63,31:[2,73],48:60,57:61,58:64,59:[1,38],63:62,64:65,65:66,66:[1,67],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{66:[1,68]},{21:[2,37],31:[2,37],52:[2,37],59:[2,37],62:[2,37],66:[2,37],69:[2,37],74:[2,37],75:[2,37],76:[2,37],77:[2,37],79:[1,43]},{18:63,51:69,52:[2,77],57:70,58:64,59:[1,38],63:71,64:65,65:66,66:[1,67],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{24:72,45:[1,73]},{45:[2,48]},{4:74,6:3,13:[2,41],14:[2,41],17:[2,41],27:[2,41],32:[2,41],37:[2,41],42:[2,41],45:[2,41],46:[2,41],49:[2,41],53:[2,41]},{45:[2,19]},{18:75,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{4:76,6:3,13:[2,41],14:[2,41],17:[2,41],27:[2,41],32:[2,41],45:[2,41],46:[2,41],49:[2,41],53:[2,41]},{24:77,45:[1,73]},{45:[2,50]},{5:[2,10],13:[2,10],14:[2,10],17:[2,10],27:[2,10],32:[2,10],37:[2,10],42:[2,10],45:[2,10],46:[2,10],49:[2,10],53:[2,10]},{18:63,31:[2,81],56:78,57:79,58:64,59:[1,38],63:80,64:65,65:66,66:[1,67],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{59:[2,83],60:81,62:[2,83],66:[2,83],74:[2,83],75:[2,83],76:[2,83],77:[2,83]},{18:63,29:82,31:[2,53],57:83,58:64,59:[1,38],63:84,64:65,65:66,66:[1,67],69:[2,53],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{18:63,31:[2,59],34:85,57:86,58:64,59:[1,38],63:87,64:65,65:66,66:[1,67],69:[2,59],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{18:63,20:88,21:[2,45],57:89,58:64,59:[1,38],63:90,64:65,65:66,66:[1,67],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{31:[1,91]},{31:[2,72],59:[2,72],66:[2,72],74:[2,72],75:[2,72],76:[2,72],77:[2,72]},{31:[2,74]},{21:[2,24],31:[2,24],52:[2,24],59:[2,24],62:[2,24],66:[2,24],69:[2,24],74:[2,24],75:[2,24],76:[2,24],77:[2,24]},{21:[2,25],31:[2,25],52:[2,25],59:[2,25],62:[2,25],66:[2,25],69:[2,25],74:[2,25],75:[2,25],76:[2,25],77:[2,25]},{21:[2,27],31:[2,27],52:[2,27],62:[2,27],65:92,66:[1,93],69:[2,27]},{21:[2,87],31:[2,87],52:[2,87],62:[2,87],66:[2,87],69:[2,87]},{21:[2,40],31:[2,40],52:[2,40],59:[2,40],62:[2,40],66:[2,40],67:[1,94],69:[2,40],74:[2,40],75:[2,40],76:[2,40],77:[2,40],79:[2,40]},{21:[2,39],31:[2,39],52:[2,39],59:[2,39],62:[2,39],66:[2,39],69:[2,39],74:[2,39],75:[2,39],76:[2,39],77:[2,39],79:[2,39]},{52:[1,95]},{52:[2,76],59:[2,76],66:[2,76],74:[2,76],75:[2,76],76:[2,76],77:[2,76]},{52:[2,78]},{5:[2,12],13:[2,12],14:[2,12],17:[2,12],27:[2,12],32:[2,12],37:[2,12],42:[2,12],45:[2,12],46:[2,12],49:[2,12],53:[2,12]},{18:96,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{36:48,37:[1,50],41:49,42:[1,51],43:98,44:97,45:[2,69]},{31:[2,63],38:99,59:[2,63],66:[2,63],69:[2,63],74:[2,63],75:[2,63],76:[2,63],77:[2,63]},{45:[2,17]},{5:[2,13],13:[2,13],14:[2,13],17:[2,13],27:[2,13],32:[2,13],37:[2,13],42:[2,13],45:[2,13],46:[2,13],49:[2,13],53:[2,13]},{31:[1,100]},{31:[2,80],59:[2,80],66:[2,80],74:[2,80],75:[2,80],76:[2,80],77:[2,80]},{31:[2,82]},{18:63,57:102,58:64,59:[1,38],61:101,62:[2,85],63:103,64:65,65:66,66:[1,67],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{30:104,31:[2,55],68:105,69:[1,106]},{31:[2,52],59:[2,52],66:[2,52],69:[2,52],74:[2,52],75:[2,52],76:[2,52],77:[2,52]},{31:[2,54],69:[2,54]},{31:[2,61],35:107,68:108,69:[1,106]},{31:[2,58],59:[2,58],66:[2,58],69:[2,58],74:[2,58],75:[2,58],76:[2,58],77:[2,58]},{31:[2,60],69:[2,60]},{21:[1,109]},{21:[2,44],59:[2,44],66:[2,44],74:[2,44],75:[2,44],76:[2,44],77:[2,44]},{21:[2,46]},{5:[2,21],13:[2,21],14:[2,21],17:[2,21],27:[2,21],32:[2,21],37:[2,21],42:[2,21],45:[2,21],46:[2,21],49:[2,21],53:[2,21]},{21:[2,88],31:[2,88],52:[2,88],62:[2,88],66:[2,88],69:[2,88]},{67:[1,94]},{18:63,57:110,58:64,59:[1,38],66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{5:[2,22],13:[2,22],14:[2,22],17:[2,22],27:[2,22],32:[2,22],37:[2,22],42:[2,22],45:[2,22],46:[2,22],49:[2,22],53:[2,22]},{31:[1,111]},{45:[2,18]},{45:[2,70]},{18:63,31:[2,65],39:112,57:113,58:64,59:[1,38],63:114,64:65,65:66,66:[1,67],69:[2,65],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{5:[2,23],13:[2,23],14:[2,23],17:[2,23],27:[2,23],32:[2,23],37:[2,23],42:[2,23],45:[2,23],46:[2,23],49:[2,23],53:[2,23]},{62:[1,115]},{59:[2,84],62:[2,84],66:[2,84],74:[2,84],75:[2,84],76:[2,84],77:[2,84]},{62:[2,86]},{31:[1,116]},{31:[2,56]},{66:[1,118],70:117},{31:[1,119]},{31:[2,62]},{14:[2,11]},{21:[2,28],31:[2,28],52:[2,28],62:[2,28],66:[2,28],69:[2,28]},{5:[2,20],13:[2,20],14:[2,20],17:[2,20],27:[2,20],32:[2,20],37:[2,20],42:[2,20],45:[2,20],46:[2,20],49:[2,20],53:[2,20]},{31:[2,67],40:120,68:121,69:[1,106]},{31:[2,64],59:[2,64],66:[2,64],69:[2,64],74:[2,64],75:[2,64],76:[2,64],77:[2,64]},{31:[2,66],69:[2,66]},{21:[2,26],31:[2,26],52:[2,26],59:[2,26],62:[2,26],66:[2,26],69:[2,26],74:[2,26],75:[2,26],76:[2,26],77:[2,26]},{13:[2,14],14:[2,14],17:[2,14],27:[2,14],32:[2,14],37:[2,14],42:[2,14],45:[2,14],46:[2,14],49:[2,14],53:[2,14]},{66:[1,123],71:[1,122]},{66:[2,89],71:[2,89]},{13:[2,15],14:[2,15],17:[2,15],27:[2,15],32:[2,15],42:[2,15],45:[2,15],46:[2,15],49:[2,15],53:[2,15]},{31:[1,124]},{31:[2,68]},{31:[2,29]},{66:[2,90],71:[2,90]},{13:[2,16],14:[2,16],17:[2,16],27:[2,16],32:[2,16],37:[2,16],42:[2,16],45:[2,16],46:[2,16],49:[2,16],53:[2,16]}],
1023
defaultActions: {4:[2,1],47:[2,48],49:[2,19],53:[2,50],62:[2,74],71:[2,78],76:[2,17],80:[2,82],90:[2,46],97:[2,18],98:[2,70],103:[2,86],105:[2,56],108:[2,62],109:[2,11],121:[2,68],122:[2,29]},
1024
parseError: function parseError(str, hash) {
1025
throw new Error(str);
1026
},
1027
parse: function parse(input) {
1028
var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
1029
this.lexer.setInput(input);
1030
this.lexer.yy = this.yy;
1031
this.yy.lexer = this.lexer;
1032
this.yy.parser = this;
1033
if (typeof this.lexer.yylloc == "undefined")
1034
this.lexer.yylloc = {};
1035
var yyloc = this.lexer.yylloc;
1036
lstack.push(yyloc);
1037
var ranges = this.lexer.options && this.lexer.options.ranges;
1038
if (typeof this.yy.parseError === "function")
1039
this.parseError = this.yy.parseError;
1040
function popStack(n) {
1041
stack.length = stack.length - 2 * n;
1042
vstack.length = vstack.length - n;
1043
lstack.length = lstack.length - n;
1044
}
1045
function lex() {
1046
var token;
1047
token = self.lexer.lex() || 1;
1048
if (typeof token !== "number") {
1049
token = self.symbols_[token] || token;
1050
}
1051
return token;
1052
}
1053
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
1054
while (true) {
1055
state = stack[stack.length - 1];
1056
if (this.defaultActions[state]) {
1057
action = this.defaultActions[state];
1058
} else {
1059
if (symbol === null || typeof symbol == "undefined") {
1060
symbol = lex();
1061
}
1062
action = table[state] && table[state][symbol];
1063
}
1064
if (typeof action === "undefined" || !action.length || !action[0]) {
1065
var errStr = "";
1066
if (!recovering) {
1067
expected = [];
1068
for (p in table[state])
1069
if (this.terminals_[p] && p > 2) {
1070
expected.push("'" + this.terminals_[p] + "'");
1071
}
1072
if (this.lexer.showPosition) {
1073
errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
1074
} else {
1075
errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'");
1076
}
1077
this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
1078
}
1079
}
1080
if (action[0] instanceof Array && action.length > 1) {
1081
throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
1082
}
1083
switch (action[0]) {
1084
case 1:
1085
stack.push(symbol);
1086
vstack.push(this.lexer.yytext);
1087
lstack.push(this.lexer.yylloc);
1088
stack.push(action[1]);
1089
symbol = null;
1090
if (!preErrorSymbol) {
1091
yyleng = this.lexer.yyleng;
1092
yytext = this.lexer.yytext;
1093
yylineno = this.lexer.yylineno;
1094
yyloc = this.lexer.yylloc;
1095
if (recovering > 0)
1096
recovering--;
1097
} else {
1098
symbol = preErrorSymbol;
1099
preErrorSymbol = null;
1100
}
1101
break;
1102
case 2:
1103
len = this.productions_[action[1]][1];
1104
yyval.$ = vstack[vstack.length - len];
1105
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};
1106
if (ranges) {
1107
yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
1108
}
1109
r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
1110
if (typeof r !== "undefined") {
1111
return r;
1112
}
1113
if (len) {
1114
stack = stack.slice(0, -1 * len * 2);
1115
vstack = vstack.slice(0, -1 * len);
1116
lstack = lstack.slice(0, -1 * len);
1117
}
1118
stack.push(this.productions_[action[1]][0]);
1119
vstack.push(yyval.$);
1120
lstack.push(yyval._$);
1121
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
1122
stack.push(newState);
1123
break;
1124
case 3:
1125
return true;
1126
}
1127
}
1128
return true;
1129
}
1130
};
1131
/* Jison generated lexer */
1132
var lexer = (function(){
1133
var lexer = ({EOF:1,
1134
parseError:function parseError(str, hash) {
1135
if (this.yy.parser) {
1136
this.yy.parser.parseError(str, hash);
1137
} else {
1138
throw new Error(str);
1139
}
1140
},
1141
setInput:function (input) {
1142
this._input = input;
1143
this._more = this._less = this.done = false;
1144
this.yylineno = this.yyleng = 0;
1145
this.yytext = this.matched = this.match = '';
1146
this.conditionStack = ['INITIAL'];
1147
this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
1148
if (this.options.ranges) this.yylloc.range = [0,0];
1149
this.offset = 0;
1150
return this;
1151
},
1152
input:function () {
1153
var ch = this._input[0];
1154
this.yytext += ch;
1155
this.yyleng++;
1156
this.offset++;
1157
this.match += ch;
1158
this.matched += ch;
1159
var lines = ch.match(/(?:\r\n?|\n).*/g);
1160
if (lines) {
1161
this.yylineno++;
1162
this.yylloc.last_line++;
1163
} else {
1164
this.yylloc.last_column++;
1165
}
1166
if (this.options.ranges) this.yylloc.range[1]++;
1167
1168
this._input = this._input.slice(1);
1169
return ch;
1170
},
1171
unput:function (ch) {
1172
var len = ch.length;
1173
var lines = ch.split(/(?:\r\n?|\n)/g);
1174
1175
this._input = ch + this._input;
1176
this.yytext = this.yytext.substr(0, this.yytext.length-len-1);
1177
//this.yyleng -= len;
1178
this.offset -= len;
1179
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
1180
this.match = this.match.substr(0, this.match.length-1);
1181
this.matched = this.matched.substr(0, this.matched.length-1);
1182
1183
if (lines.length-1) this.yylineno -= lines.length-1;
1184
var r = this.yylloc.range;
1185
1186
this.yylloc = {first_line: this.yylloc.first_line,
1187
last_line: this.yylineno+1,
1188
first_column: this.yylloc.first_column,
1189
last_column: lines ?
1190
(lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length:
1191
this.yylloc.first_column - len
1192
};
1193
1194
if (this.options.ranges) {
1195
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
1196
}
1197
return this;
1198
},
1199
more:function () {
1200
this._more = true;
1201
return this;
1202
},
1203
less:function (n) {
1204
this.unput(this.match.slice(n));
1205
},
1206
pastInput:function () {
1207
var past = this.matched.substr(0, this.matched.length - this.match.length);
1208
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
1209
},
1210
upcomingInput:function () {
1211
var next = this.match;
1212
if (next.length < 20) {
1213
next += this._input.substr(0, 20-next.length);
1214
}
1215
return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
1216
},
1217
showPosition:function () {
1218
var pre = this.pastInput();
1219
var c = new Array(pre.length + 1).join("-");
1220
return pre + this.upcomingInput() + "\n" + c+"^";
1221
},
1222
next:function () {
1223
if (this.done) {
1224
return this.EOF;
1225
}
1226
if (!this._input) this.done = true;
1227
1228
var token,
1229
match,
1230
tempMatch,
1231
index,
1232
col,
1233
lines;
1234
if (!this._more) {
1235
this.yytext = '';
1236
this.match = '';
1237
}
1238
var rules = this._currentRules();
1239
for (var i=0;i < rules.length; i++) {
1240
tempMatch = this._input.match(this.rules[rules[i]]);
1241
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
1242
match = tempMatch;
1243
index = i;
1244
if (!this.options.flex) break;
1245
}
1246
}
1247
if (match) {
1248
lines = match[0].match(/(?:\r\n?|\n).*/g);
1249
if (lines) this.yylineno += lines.length;
1250
this.yylloc = {first_line: this.yylloc.last_line,
1251
last_line: this.yylineno+1,
1252
first_column: this.yylloc.last_column,
1253
last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length};
1254
this.yytext += match[0];
1255
this.match += match[0];
1256
this.matches = match;
1257
this.yyleng = this.yytext.length;
1258
if (this.options.ranges) {
1259
this.yylloc.range = [this.offset, this.offset += this.yyleng];
1260
}
1261
this._more = false;
1262
this._input = this._input.slice(match[0].length);
1263
this.matched += match[0];
1264
token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
1265
if (this.done && this._input) this.done = false;
1266
if (token) return token;
1267
else return;
1268
}
1269
if (this._input === "") {
1270
return this.EOF;
1271
} else {
1272
return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
1273
{text: "", token: null, line: this.yylineno});
1274
}
1275
},
1276
lex:function lex() {
1277
var r = this.next();
1278
if (typeof r !== 'undefined') {
1279
return r;
1280
} else {
1281
return this.lex();
1282
}
1283
},
1284
begin:function begin(condition) {
1285
this.conditionStack.push(condition);
1286
},
1287
popState:function popState() {
1288
return this.conditionStack.pop();
1289
},
1290
_currentRules:function _currentRules() {
1291
return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
1292
},
1293
topState:function () {
1294
return this.conditionStack[this.conditionStack.length-2];
1295
},
1296
pushState:function begin(condition) {
1297
this.begin(condition);
1298
}});
1299
lexer.options = {};
1300
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
1301
1302
1303
function strip(start, end) {
1304
return yy_.yytext = yy_.yytext.substr(start, yy_.yyleng-end);
1305
}
1306
1307
1308
var YYSTATE=YY_START
1309
switch($avoiding_name_collisions) {
1310
case 0:
1311
if(yy_.yytext.slice(-2) === "\\\\") {
1312
strip(0,1);
1313
this.begin("mu");
1314
} else if(yy_.yytext.slice(-1) === "\\") {
1315
strip(0,1);
1316
this.begin("emu");
1317
} else {
1318
this.begin("mu");
1319
}
1320
if(yy_.yytext) return 14;
1321
1322
break;
1323
case 1:return 14;
1324
break;
1325
case 2:
1326
this.popState();
1327
return 14;
1328
1329
break;
1330
case 3:
1331
yy_.yytext = yy_.yytext.substr(5, yy_.yyleng-9);
1332
this.popState();
1333
return 16;
1334
1335
break;
1336
case 4: return 14;
1337
break;
1338
case 5:
1339
this.popState();
1340
return 13;
1341
1342
break;
1343
case 6:return 59;
1344
break;
1345
case 7:return 62;
1346
break;
1347
case 8: return 17;
1348
break;
1349
case 9:
1350
this.popState();
1351
this.begin('raw');
1352
return 21;
1353
1354
break;
1355
case 10:return 53;
1356
break;
1357
case 11:return 27;
1358
break;
1359
case 12:return 45;
1360
break;
1361
case 13:this.popState(); return 42;
1362
break;
1363
case 14:this.popState(); return 42;
1364
break;
1365
case 15:return 32;
1366
break;
1367
case 16:return 37;
1368
break;
1369
case 17:return 49;
1370
break;
1371
case 18:return 46;
1372
break;
1373
case 19:
1374
this.unput(yy_.yytext);
1375
this.popState();
1376
this.begin('com');
1377
1378
break;
1379
case 20:
1380
this.popState();
1381
return 13;
1382
1383
break;
1384
case 21:return 46;
1385
break;
1386
case 22:return 67;
1387
break;
1388
case 23:return 66;
1389
break;
1390
case 24:return 66;
1391
break;
1392
case 25:return 79;
1393
break;
1394
case 26:// ignore whitespace
1395
break;
1396
case 27:this.popState(); return 52;
1397
break;
1398
case 28:this.popState(); return 31;
1399
break;
1400
case 29:yy_.yytext = strip(1,2).replace(/\\"/g,'"'); return 74;
1401
break;
1402
case 30:yy_.yytext = strip(1,2).replace(/\\'/g,"'"); return 74;
1403
break;
1404
case 31:return 77;
1405
break;
1406
case 32:return 76;
1407
break;
1408
case 33:return 76;
1409
break;
1410
case 34:return 75;
1411
break;
1412
case 35:return 69;
1413
break;
1414
case 36:return 71;
1415
break;
1416
case 37:return 66;
1417
break;
1418
case 38:yy_.yytext = strip(1,2); return 66;
1419
break;
1420
case 39:return 'INVALID';
1421
break;
1422
case 40:return 5;
1423
break;
1424
}
1425
};
1426
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)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
1427
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,39,40],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"com":{"rules":[5],"inclusive":false},"raw":{"rules":[3,4],"inclusive":false},"INITIAL":{"rules":[0,1,40],"inclusive":true}};
1428
return lexer;})()
1429
parser.lexer = lexer;
1430
function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
1431
return new Parser;
1432
})();__exports__ = handlebars;
1433
/* jshint ignore:end */
1434
return __exports__;
1435
})();
1436
1437
// handlebars/compiler/visitor.js
1438
var __module11__ = (function(__dependency1__, __dependency2__) {
1439
"use strict";
1440
var __exports__;
1441
var Exception = __dependency1__;
1442
var AST = __dependency2__;
1443
1444
function Visitor() {
1445
this.parents = [];
1446
}
1447
1448
Visitor.prototype = {
1449
constructor: Visitor,
1450
mutating: false,
1451
1452
// Visits a given value. If mutating, will replace the value if necessary.
1453
acceptKey: function(node, name) {
1454
var value = this.accept(node[name]);
1455
if (this.mutating) {
1456
// Hacky sanity check:
1457
if (value && (!value.type || !AST[value.type])) {
1458
throw new Exception('Unexpected node type "' + value.type + '" found when accepting ' + name + ' on ' + node.type);
1459
}
1460
node[name] = value;
1461
}
1462
},
1463
1464
// Performs an accept operation with added sanity check to ensure
1465
// required keys are not removed.
1466
acceptRequired: function(node, name) {
1467
this.acceptKey(node, name);
1468
1469
if (!node[name]) {
1470
throw new Exception(node.type + ' requires ' + name);
1471
}
1472
},
1473
1474
// Traverses a given array. If mutating, empty respnses will be removed
1475
// for child elements.
1476
acceptArray: function(array) {
1477
for (var i = 0, l = array.length; i < l; i++) {
1478
this.acceptKey(array, i);
1479
1480
if (!array[i]) {
1481
array.splice(i, 1);
1482
i--;
1483
l--;
1484
}
1485
}
1486
},
1487
1488
accept: function(object) {
1489
if (!object) {
1490
return;
1491
}
1492
1493
if (this.current) {
1494
this.parents.unshift(this.current);
1495
}
1496
this.current = object;
1497
1498
var ret = this[object.type](object);
1499
1500
this.current = this.parents.shift();
1501
1502
if (!this.mutating || ret) {
1503
return ret;
1504
} else if (ret !== false) {
1505
return object;
1506
}
1507
},
1508
1509
Program: function(program) {
1510
this.acceptArray(program.body);
1511
},
1512
1513
MustacheStatement: function(mustache) {
1514
this.acceptRequired(mustache, 'path');
1515
this.acceptArray(mustache.params);
1516
this.acceptKey(mustache, 'hash');
1517
},
1518
1519
BlockStatement: function(block) {
1520
this.acceptRequired(block, 'path');
1521
this.acceptArray(block.params);
1522
this.acceptKey(block, 'hash');
1523
1524
this.acceptKey(block, 'program');
1525
this.acceptKey(block, 'inverse');
1526
},
1527
1528
PartialStatement: function(partial) {
1529
this.acceptRequired(partial, 'name');
1530
this.acceptArray(partial.params);
1531
this.acceptKey(partial, 'hash');
1532
},
1533
1534
ContentStatement: function(/* content */) {},
1535
CommentStatement: function(/* comment */) {},
1536
1537
SubExpression: function(sexpr) {
1538
this.acceptRequired(sexpr, 'path');
1539
this.acceptArray(sexpr.params);
1540
this.acceptKey(sexpr, 'hash');
1541
},
1542
PartialExpression: function(partial) {
1543
this.acceptRequired(partial, 'name');
1544
this.acceptArray(partial.params);
1545
this.acceptKey(partial, 'hash');
1546
},
1547
1548
PathExpression: function(/* path */) {},
1549
1550
StringLiteral: function(/* string */) {},
1551
NumberLiteral: function(/* number */) {},
1552
BooleanLiteral: function(/* bool */) {},
1553
1554
Hash: function(hash) {
1555
this.acceptArray(hash.pairs);
1556
},
1557
HashPair: function(pair) {
1558
this.acceptRequired(pair, 'value');
1559
}
1560
};
1561
1562
__exports__ = Visitor;
1563
return __exports__;
1564
})(__module4__, __module7__);
1565
1566
// handlebars/compiler/whitespace-control.js
1567
var __module10__ = (function(__dependency1__) {
1568
"use strict";
1569
var __exports__;
1570
var Visitor = __dependency1__;
1571
1572
function WhitespaceControl() {
1573
}
1574
WhitespaceControl.prototype = new Visitor();
1575
1576
WhitespaceControl.prototype.Program = function(program) {
1577
var isRoot = !this.isRootSeen;
1578
this.isRootSeen = true;
1579
1580
var body = program.body;
1581
for (var i = 0, l = body.length; i < l; i++) {
1582
var current = body[i],
1583
strip = this.accept(current);
1584
1585
if (!strip) {
1586
continue;
1587
}
1588
1589
var _isPrevWhitespace = isPrevWhitespace(body, i, isRoot),
1590
_isNextWhitespace = isNextWhitespace(body, i, isRoot),
1591
1592
openStandalone = strip.openStandalone && _isPrevWhitespace,
1593
closeStandalone = strip.closeStandalone && _isNextWhitespace,
1594
inlineStandalone = strip.inlineStandalone && _isPrevWhitespace && _isNextWhitespace;
1595
1596
if (strip.close) {
1597
omitRight(body, i, true);
1598
}
1599
if (strip.open) {
1600
omitLeft(body, i, true);
1601
}
1602
1603
if (inlineStandalone) {
1604
omitRight(body, i);
1605
1606
if (omitLeft(body, i)) {
1607
// If we are on a standalone node, save the indent info for partials
1608
if (current.type === 'PartialStatement') {
1609
// Pull out the whitespace from the final line
1610
current.indent = (/([ \t]+$)/).exec(body[i-1].original)[1];
1611
}
1612
}
1613
}
1614
if (openStandalone) {
1615
omitRight((current.program || current.inverse).body);
1616
1617
// Strip out the previous content node if it's whitespace only
1618
omitLeft(body, i);
1619
}
1620
if (closeStandalone) {
1621
// Always strip the next node
1622
omitRight(body, i);
1623
1624
omitLeft((current.inverse || current.program).body);
1625
}
1626
}
1627
1628
return program;
1629
};
1630
WhitespaceControl.prototype.BlockStatement = function(block) {
1631
this.accept(block.program);
1632
this.accept(block.inverse);
1633
1634
// Find the inverse program that is involed with whitespace stripping.
1635
var program = block.program || block.inverse,
1636
inverse = block.program && block.inverse,
1637
firstInverse = inverse,
1638
lastInverse = inverse;
1639
1640
if (inverse && inverse.chained) {
1641
firstInverse = inverse.body[0].program;
1642
1643
// Walk the inverse chain to find the last inverse that is actually in the chain.
1644
while (lastInverse.chained) {
1645
lastInverse = lastInverse.body[lastInverse.body.length-1].program;
1646
}
1647
}
1648
1649
var strip = {
1650
open: block.openStrip.open,
1651
close: block.closeStrip.close,
1652
1653
// Determine the standalone candiacy. Basically flag our content as being possibly standalone
1654
// so our parent can determine if we actually are standalone
1655
openStandalone: isNextWhitespace(program.body),
1656
closeStandalone: isPrevWhitespace((firstInverse || program).body)
1657
};
1658
1659
if (block.openStrip.close) {
1660
omitRight(program.body, null, true);
1661
}
1662
1663
if (inverse) {
1664
var inverseStrip = block.inverseStrip;
1665
1666
if (inverseStrip.open) {
1667
omitLeft(program.body, null, true);
1668
}
1669
1670
if (inverseStrip.close) {
1671
omitRight(firstInverse.body, null, true);
1672
}
1673
if (block.closeStrip.open) {
1674
omitLeft(lastInverse.body, null, true);
1675
}
1676
1677
// Find standalone else statments
1678
if (isPrevWhitespace(program.body)
1679
&& isNextWhitespace(firstInverse.body)) {
1680
1681
omitLeft(program.body);
1682
omitRight(firstInverse.body);
1683
}
1684
} else {
1685
if (block.closeStrip.open) {
1686
omitLeft(program.body, null, true);
1687
}
1688
}
1689
1690
return strip;
1691
};
1692
1693
WhitespaceControl.prototype.MustacheStatement = function(mustache) {
1694
return mustache.strip;
1695
};
1696
1697
WhitespaceControl.prototype.PartialStatement =
1698
WhitespaceControl.prototype.CommentStatement = function(node) {
1699
/* istanbul ignore next */
1700
var strip = node.strip || {};
1701
return {
1702
inlineStandalone: true,
1703
open: strip.open,
1704
close: strip.close
1705
};
1706
};
1707
1708
1709
function isPrevWhitespace(body, i, isRoot) {
1710
if (i === undefined) {
1711
i = body.length;
1712
}
1713
1714
// Nodes that end with newlines are considered whitespace (but are special
1715
// cased for strip operations)
1716
var prev = body[i-1],
1717
sibling = body[i-2];
1718
if (!prev) {
1719
return isRoot;
1720
}
1721
1722
if (prev.type === 'ContentStatement') {
1723
return (sibling || !isRoot ? (/\r?\n\s*?$/) : (/(^|\r?\n)\s*?$/)).test(prev.original);
1724
}
1725
}
1726
function isNextWhitespace(body, i, isRoot) {
1727
if (i === undefined) {
1728
i = -1;
1729
}
1730
1731
var next = body[i+1],
1732
sibling = body[i+2];
1733
if (!next) {
1734
return isRoot;
1735
}
1736
1737
if (next.type === 'ContentStatement') {
1738
return (sibling || !isRoot ? (/^\s*?\r?\n/) : (/^\s*?(\r?\n|$)/)).test(next.original);
1739
}
1740
}
1741
1742
// Marks the node to the right of the position as omitted.
1743
// I.e. {{foo}}' ' will mark the ' ' node as omitted.
1744
//
1745
// If i is undefined, then the first child will be marked as such.
1746
//
1747
// If mulitple is truthy then all whitespace will be stripped out until non-whitespace
1748
// content is met.
1749
function omitRight(body, i, multiple) {
1750
var current = body[i == null ? 0 : i + 1];
1751
if (!current || current.type !== 'ContentStatement' || (!multiple && current.rightStripped)) {
1752
return;
1753
}
1754
1755
var original = current.value;
1756
current.value = current.value.replace(multiple ? (/^\s+/) : (/^[ \t]*\r?\n?/), '');
1757
current.rightStripped = current.value !== original;
1758
}
1759
1760
// Marks the node to the left of the position as omitted.
1761
// I.e. ' '{{foo}} will mark the ' ' node as omitted.
1762
//
1763
// If i is undefined then the last child will be marked as such.
1764
//
1765
// If mulitple is truthy then all whitespace will be stripped out until non-whitespace
1766
// content is met.
1767
function omitLeft(body, i, multiple) {
1768
var current = body[i == null ? body.length - 1 : i - 1];
1769
if (!current || current.type !== 'ContentStatement' || (!multiple && current.leftStripped)) {
1770
return;
1771
}
1772
1773
// We omit the last node if it's whitespace only and not preceeded by a non-content node.
1774
var original = current.value;
1775
current.value = current.value.replace(multiple ? (/\s+$/) : (/[ \t]+$/), '');
1776
current.leftStripped = current.value !== original;
1777
return current.leftStripped;
1778
}
1779
1780
__exports__ = WhitespaceControl;
1781
return __exports__;
1782
})(__module11__);
1783
1784
// handlebars/compiler/helpers.js
1785
var __module12__ = (function(__dependency1__) {
1786
"use strict";
1787
var __exports__ = {};
1788
var Exception = __dependency1__;
1789
1790
function SourceLocation(source, locInfo) {
1791
this.source = source;
1792
this.start = {
1793
line: locInfo.first_line,
1794
column: locInfo.first_column
1795
};
1796
this.end = {
1797
line: locInfo.last_line,
1798
column: locInfo.last_column
1799
};
1800
}
1801
1802
__exports__.SourceLocation = SourceLocation;function stripFlags(open, close) {
1803
return {
1804
open: open.charAt(2) === '~',
1805
close: close.charAt(close.length-3) === '~'
1806
};
1807
}
1808
1809
__exports__.stripFlags = stripFlags;function stripComment(comment) {
1810
return comment.replace(/^\{\{~?\!-?-?/, '')
1811
.replace(/-?-?~?\}\}$/, '');
1812
}
1813
1814
__exports__.stripComment = stripComment;function preparePath(data, parts, locInfo) {
1815
/*jshint -W040 */
1816
locInfo = this.locInfo(locInfo);
1817
1818
var original = data ? '@' : '',
1819
dig = [],
1820
depth = 0,
1821
depthString = '';
1822
1823
for(var i=0,l=parts.length; i<l; i++) {
1824
var part = parts[i].part;
1825
original += (parts[i].separator || '') + part;
1826
1827
if (part === '..' || part === '.' || part === 'this') {
1828
if (dig.length > 0) {
1829
throw new Exception('Invalid path: ' + original, {loc: locInfo});
1830
} else if (part === '..') {
1831
depth++;
1832
depthString += '../';
1833
}
1834
} else {
1835
dig.push(part);
1836
}
1837
}
1838
1839
return new this.PathExpression(data, depth, dig, original, locInfo);
1840
}
1841
1842
__exports__.preparePath = preparePath;function prepareMustache(path, params, hash, open, strip, locInfo) {
1843
/*jshint -W040 */
1844
// Must use charAt to support IE pre-10
1845
var escapeFlag = open.charAt(3) || open.charAt(2),
1846
escaped = escapeFlag !== '{' && escapeFlag !== '&';
1847
1848
return new this.MustacheStatement(path, params, hash, escaped, strip, this.locInfo(locInfo));
1849
}
1850
1851
__exports__.prepareMustache = prepareMustache;function prepareRawBlock(openRawBlock, content, close, locInfo) {
1852
/*jshint -W040 */
1853
if (openRawBlock.path.original !== close) {
1854
var errorNode = {loc: openRawBlock.path.loc};
1855
1856
throw new Exception(openRawBlock.path.original + " doesn't match " + close, errorNode);
1857
}
1858
1859
locInfo = this.locInfo(locInfo);
1860
var program = new this.Program([content], null, {}, locInfo);
1861
1862
return new this.BlockStatement(
1863
openRawBlock.path, openRawBlock.params, openRawBlock.hash,
1864
program, undefined,
1865
{}, {}, {},
1866
locInfo);
1867
}
1868
1869
__exports__.prepareRawBlock = prepareRawBlock;function prepareBlock(openBlock, program, inverseAndProgram, close, inverted, locInfo) {
1870
/*jshint -W040 */
1871
// When we are chaining inverse calls, we will not have a close path
1872
if (close && close.path && openBlock.path.original !== close.path.original) {
1873
var errorNode = {loc: openBlock.path.loc};
1874
1875
throw new Exception(openBlock.path.original + ' doesn\'t match ' + close.path.original, errorNode);
1876
}
1877
1878
program.blockParams = openBlock.blockParams;
1879
1880
var inverse,
1881
inverseStrip;
1882
1883
if (inverseAndProgram) {
1884
if (inverseAndProgram.chain) {
1885
inverseAndProgram.program.body[0].closeStrip = close.strip;
1886
}
1887
1888
inverseStrip = inverseAndProgram.strip;
1889
inverse = inverseAndProgram.program;
1890
}
1891
1892
if (inverted) {
1893
inverted = inverse;
1894
inverse = program;
1895
program = inverted;
1896
}
1897
1898
return new this.BlockStatement(
1899
openBlock.path, openBlock.params, openBlock.hash,
1900
program, inverse,
1901
openBlock.strip, inverseStrip, close && close.strip,
1902
this.locInfo(locInfo));
1903
}
1904
1905
__exports__.prepareBlock = prepareBlock;
1906
return __exports__;
1907
})(__module4__);
1908
1909
// handlebars/compiler/base.js
1910
var __module8__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {
1911
"use strict";
1912
var __exports__ = {};
1913
var parser = __dependency1__;
1914
var AST = __dependency2__;
1915
var WhitespaceControl = __dependency3__;
1916
var Helpers = __dependency4__;
1917
var extend = __dependency5__.extend;
1918
1919
__exports__.parser = parser;
1920
1921
var yy = {};
1922
extend(yy, Helpers, AST);
1923
1924
function parse(input, options) {
1925
// Just return if an already-compiled AST was passed in.
1926
if (input.type === 'Program') { return input; }
1927
1928
parser.yy = yy;
1929
1930
// Altering the shared object here, but this is ok as parser is a sync operation
1931
yy.locInfo = function(locInfo) {
1932
return new yy.SourceLocation(options && options.srcName, locInfo);
1933
};
1934
1935
var strip = new WhitespaceControl();
1936
return strip.accept(parser.parse(input));
1937
}
1938
1939
__exports__.parse = parse;
1940
return __exports__;
1941
})(__module9__, __module7__, __module10__, __module12__, __module3__);
1942
1943
// handlebars/compiler/compiler.js
1944
var __module13__ = (function(__dependency1__, __dependency2__, __dependency3__) {
1945
"use strict";
1946
var __exports__ = {};
1947
var Exception = __dependency1__;
1948
var isArray = __dependency2__.isArray;
1949
var indexOf = __dependency2__.indexOf;
1950
var AST = __dependency3__;
1951
1952
var slice = [].slice;
1953
1954
1955
function Compiler() {}
1956
1957
__exports__.Compiler = Compiler;// the foundHelper register will disambiguate helper lookup from finding a
1958
// function in a context. This is necessary for mustache compatibility, which
1959
// requires that context functions in blocks are evaluated by blockHelperMissing,
1960
// and then proceed as if the resulting value was provided to blockHelperMissing.
1961
1962
Compiler.prototype = {
1963
compiler: Compiler,
1964
1965
equals: function(other) {
1966
var len = this.opcodes.length;
1967
if (other.opcodes.length !== len) {
1968
return false;
1969
}
1970
1971
for (var i = 0; i < len; i++) {
1972
var opcode = this.opcodes[i],
1973
otherOpcode = other.opcodes[i];
1974
if (opcode.opcode !== otherOpcode.opcode || !argEquals(opcode.args, otherOpcode.args)) {
1975
return false;
1976
}
1977
}
1978
1979
// We know that length is the same between the two arrays because they are directly tied
1980
// to the opcode behavior above.
1981
len = this.children.length;
1982
for (i = 0; i < len; i++) {
1983
if (!this.children[i].equals(other.children[i])) {
1984
return false;
1985
}
1986
}
1987
1988
return true;
1989
},
1990
1991
guid: 0,
1992
1993
compile: function(program, options) {
1994
this.sourceNode = [];
1995
this.opcodes = [];
1996
this.children = [];
1997
this.options = options;
1998
this.stringParams = options.stringParams;
1999
this.trackIds = options.trackIds;
2000
2001
options.blockParams = options.blockParams || [];
2002
2003
// These changes will propagate to the other compiler components
2004
var knownHelpers = options.knownHelpers;
2005
options.knownHelpers = {
2006
'helperMissing': true,
2007
'blockHelperMissing': true,
2008
'each': true,
2009
'if': true,
2010
'unless': true,
2011
'with': true,
2012
'log': true,
2013
'lookup': true
2014
};
2015
if (knownHelpers) {
2016
for (var name in knownHelpers) {
2017
options.knownHelpers[name] = knownHelpers[name];
2018
}
2019
}
2020
2021
return this.accept(program);
2022
},
2023
2024
compileProgram: function(program) {
2025
var result = new this.compiler().compile(program, this.options);
2026
var guid = this.guid++;
2027
2028
this.usePartial = this.usePartial || result.usePartial;
2029
2030
this.children[guid] = result;
2031
this.useDepths = this.useDepths || result.useDepths;
2032
2033
return guid;
2034
},
2035
2036
accept: function(node) {
2037
this.sourceNode.unshift(node);
2038
var ret = this[node.type](node);
2039
this.sourceNode.shift();
2040
return ret;
2041
},
2042
2043
Program: function(program) {
2044
this.options.blockParams.unshift(program.blockParams);
2045
2046
var body = program.body;
2047
for(var i=0, l=body.length; i<l; i++) {
2048
this.accept(body[i]);
2049
}
2050
2051
this.options.blockParams.shift();
2052
2053
this.isSimple = l === 1;
2054
this.blockParams = program.blockParams ? program.blockParams.length : 0;
2055
2056
return this;
2057
},
2058
2059
BlockStatement: function(block) {
2060
transformLiteralToPath(block);
2061
2062
var program = block.program,
2063
inverse = block.inverse;
2064
2065
program = program && this.compileProgram(program);
2066
inverse = inverse && this.compileProgram(inverse);
2067
2068
var type = this.classifySexpr(block);
2069
2070
if (type === 'helper') {
2071
this.helperSexpr(block, program, inverse);
2072
} else if (type === 'simple') {
2073
this.simpleSexpr(block);
2074
2075
// now that the simple mustache is resolved, we need to
2076
// evaluate it by executing `blockHelperMissing`
2077
this.opcode('pushProgram', program);
2078
this.opcode('pushProgram', inverse);
2079
this.opcode('emptyHash');
2080
this.opcode('blockValue', block.path.original);
2081
} else {
2082
this.ambiguousSexpr(block, program, inverse);
2083
2084
// now that the simple mustache is resolved, we need to
2085
// evaluate it by executing `blockHelperMissing`
2086
this.opcode('pushProgram', program);
2087
this.opcode('pushProgram', inverse);
2088
this.opcode('emptyHash');
2089
this.opcode('ambiguousBlockValue');
2090
}
2091
2092
this.opcode('append');
2093
},
2094
2095
PartialStatement: function(partial) {
2096
this.usePartial = true;
2097
2098
var params = partial.params;
2099
if (params.length > 1) {
2100
throw new Exception('Unsupported number of partial arguments: ' + params.length, partial);
2101
} else if (!params.length) {
2102
params.push({type: 'PathExpression', parts: [], depth: 0});
2103
}
2104
2105
var partialName = partial.name.original,
2106
isDynamic = partial.name.type === 'SubExpression';
2107
if (isDynamic) {
2108
this.accept(partial.name);
2109
}
2110
2111
this.setupFullMustacheParams(partial, undefined, undefined, true);
2112
2113
var indent = partial.indent || '';
2114
if (this.options.preventIndent && indent) {
2115
this.opcode('appendContent', indent);
2116
indent = '';
2117
}
2118
2119
this.opcode('invokePartial', isDynamic, partialName, indent);
2120
this.opcode('append');
2121
},
2122
2123
MustacheStatement: function(mustache) {
2124
this.SubExpression(mustache);
2125
2126
if(mustache.escaped && !this.options.noEscape) {
2127
this.opcode('appendEscaped');
2128
} else {
2129
this.opcode('append');
2130
}
2131
},
2132
2133
ContentStatement: function(content) {
2134
if (content.value) {
2135
this.opcode('appendContent', content.value);
2136
}
2137
},
2138
2139
CommentStatement: function() {},
2140
2141
SubExpression: function(sexpr) {
2142
transformLiteralToPath(sexpr);
2143
var type = this.classifySexpr(sexpr);
2144
2145
if (type === 'simple') {
2146
this.simpleSexpr(sexpr);
2147
} else if (type === 'helper') {
2148
this.helperSexpr(sexpr);
2149
} else {
2150
this.ambiguousSexpr(sexpr);
2151
}
2152
},
2153
ambiguousSexpr: function(sexpr, program, inverse) {
2154
var path = sexpr.path,
2155
name = path.parts[0],
2156
isBlock = program != null || inverse != null;
2157
2158
this.opcode('getContext', path.depth);
2159
2160
this.opcode('pushProgram', program);
2161
this.opcode('pushProgram', inverse);
2162
2163
this.accept(path);
2164
2165
this.opcode('invokeAmbiguous', name, isBlock);
2166
},
2167
2168
simpleSexpr: function(sexpr) {
2169
this.accept(sexpr.path);
2170
this.opcode('resolvePossibleLambda');
2171
},
2172
2173
helperSexpr: function(sexpr, program, inverse) {
2174
var params = this.setupFullMustacheParams(sexpr, program, inverse),
2175
path = sexpr.path,
2176
name = path.parts[0];
2177
2178
if (this.options.knownHelpers[name]) {
2179
this.opcode('invokeKnownHelper', params.length, name);
2180
} else if (this.options.knownHelpersOnly) {
2181
throw new Exception("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr);
2182
} else {
2183
path.falsy = true;
2184
2185
this.accept(path);
2186
this.opcode('invokeHelper', params.length, path.original, AST.helpers.simpleId(path));
2187
}
2188
},
2189
2190
PathExpression: function(path) {
2191
this.addDepth(path.depth);
2192
this.opcode('getContext', path.depth);
2193
2194
var name = path.parts[0],
2195
scoped = AST.helpers.scopedId(path),
2196
blockParamId = !path.depth && !scoped && this.blockParamIndex(name);
2197
2198
if (blockParamId) {
2199
this.opcode('lookupBlockParam', blockParamId, path.parts);
2200
} else if (!name) {
2201
// Context reference, i.e. `{{foo .}}` or `{{foo ..}}`
2202
this.opcode('pushContext');
2203
} else if (path.data) {
2204
this.options.data = true;
2205
this.opcode('lookupData', path.depth, path.parts);
2206
} else {
2207
this.opcode('lookupOnContext', path.parts, path.falsy, scoped);
2208
}
2209
},
2210
2211
StringLiteral: function(string) {
2212
this.opcode('pushString', string.value);
2213
},
2214
2215
NumberLiteral: function(number) {
2216
this.opcode('pushLiteral', number.value);
2217
},
2218
2219
BooleanLiteral: function(bool) {
2220
this.opcode('pushLiteral', bool.value);
2221
},
2222
2223
Hash: function(hash) {
2224
var pairs = hash.pairs, i, l;
2225
2226
this.opcode('pushHash');
2227
2228
for (i=0, l=pairs.length; i<l; i++) {
2229
this.pushParam(pairs[i].value);
2230
}
2231
while (i--) {
2232
this.opcode('assignToHash', pairs[i].key);
2233
}
2234
this.opcode('popHash');
2235
},
2236
2237
// HELPERS
2238
opcode: function(name) {
2239
this.opcodes.push({ opcode: name, args: slice.call(arguments, 1), loc: this.sourceNode[0].loc });
2240
},
2241
2242
addDepth: function(depth) {
2243
if (!depth) {
2244
return;
2245
}
2246
2247
this.useDepths = true;
2248
},
2249
2250
classifySexpr: function(sexpr) {
2251
var isSimple = AST.helpers.simpleId(sexpr.path);
2252
2253
var isBlockParam = isSimple && !!this.blockParamIndex(sexpr.path.parts[0]);
2254
2255
// a mustache is an eligible helper if:
2256
// * its id is simple (a single part, not `this` or `..`)
2257
var isHelper = !isBlockParam && AST.helpers.helperExpression(sexpr);
2258
2259
// if a mustache is an eligible helper but not a definite
2260
// helper, it is ambiguous, and will be resolved in a later
2261
// pass or at runtime.
2262
var isEligible = !isBlockParam && (isHelper || isSimple);
2263
2264
var options = this.options;
2265
2266
// if ambiguous, we can possibly resolve the ambiguity now
2267
// An eligible helper is one that does not have a complex path, i.e. `this.foo`, `../foo` etc.
2268
if (isEligible && !isHelper) {
2269
var name = sexpr.path.parts[0];
2270
2271
if (options.knownHelpers[name]) {
2272
isHelper = true;
2273
} else if (options.knownHelpersOnly) {
2274
isEligible = false;
2275
}
2276
}
2277
2278
if (isHelper) { return 'helper'; }
2279
else if (isEligible) { return 'ambiguous'; }
2280
else { return 'simple'; }
2281
},
2282
2283
pushParams: function(params) {
2284
for(var i=0, l=params.length; i<l; i++) {
2285
this.pushParam(params[i]);
2286
}
2287
},
2288
2289
pushParam: function(val) {
2290
var value = val.value != null ? val.value : val.original || '';
2291
2292
if (this.stringParams) {
2293
if (value.replace) {
2294
value = value
2295
.replace(/^(\.?\.\/)*/g, '')
2296
.replace(/\//g, '.');
2297
}
2298
2299
if(val.depth) {
2300
this.addDepth(val.depth);
2301
}
2302
this.opcode('getContext', val.depth || 0);
2303
this.opcode('pushStringParam', value, val.type);
2304
2305
if (val.type === 'SubExpression') {
2306
// SubExpressions get evaluated and passed in
2307
// in string params mode.
2308
this.accept(val);
2309
}
2310
} else {
2311
if (this.trackIds) {
2312
var blockParamIndex;
2313
if (val.parts && !AST.helpers.scopedId(val) && !val.depth) {
2314
blockParamIndex = this.blockParamIndex(val.parts[0]);
2315
}
2316
if (blockParamIndex) {
2317
var blockParamChild = val.parts.slice(1).join('.');
2318
this.opcode('pushId', 'BlockParam', blockParamIndex, blockParamChild);
2319
} else {
2320
value = val.original || value;
2321
if (value.replace) {
2322
value = value
2323
.replace(/^\.\//g, '')
2324
.replace(/^\.$/g, '');
2325
}
2326
2327
this.opcode('pushId', val.type, value);
2328
}
2329
}
2330
this.accept(val);
2331
}
2332
},
2333
2334
setupFullMustacheParams: function(sexpr, program, inverse, omitEmpty) {
2335
var params = sexpr.params;
2336
this.pushParams(params);
2337
2338
this.opcode('pushProgram', program);
2339
this.opcode('pushProgram', inverse);
2340
2341
if (sexpr.hash) {
2342
this.accept(sexpr.hash);
2343
} else {
2344
this.opcode('emptyHash', omitEmpty);
2345
}
2346
2347
return params;
2348
},
2349
2350
blockParamIndex: function(name) {
2351
for (var depth = 0, len = this.options.blockParams.length; depth < len; depth++) {
2352
var blockParams = this.options.blockParams[depth],
2353
param = blockParams && indexOf(blockParams, name);
2354
if (blockParams && param >= 0) {
2355
return [depth, param];
2356
}
2357
}
2358
}
2359
};
2360
2361
function precompile(input, options, env) {
2362
if (input == null || (typeof input !== 'string' && input.type !== 'Program')) {
2363
throw new Exception("You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input);
2364
}
2365
2366
options = options || {};
2367
if (!('data' in options)) {
2368
options.data = true;
2369
}
2370
if (options.compat) {
2371
options.useDepths = true;
2372
}
2373
2374
var ast = env.parse(input, options);
2375
var environment = new env.Compiler().compile(ast, options);
2376
return new env.JavaScriptCompiler().compile(environment, options);
2377
}
2378
2379
__exports__.precompile = precompile;function compile(input, options, env) {
2380
if (input == null || (typeof input !== 'string' && input.type !== 'Program')) {
2381
throw new Exception("You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input);
2382
}
2383
2384
options = options || {};
2385
2386
if (!('data' in options)) {
2387
options.data = true;
2388
}
2389
if (options.compat) {
2390
options.useDepths = true;
2391
}
2392
2393
var compiled;
2394
2395
function compileInput() {
2396
var ast = env.parse(input, options);
2397
var environment = new env.Compiler().compile(ast, options);
2398
var templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);
2399
return env.template(templateSpec);
2400
}
2401
2402
// Template is only compiled on first use and cached after that point.
2403
var ret = function(context, options) {
2404
if (!compiled) {
2405
compiled = compileInput();
2406
}
2407
return compiled.call(this, context, options);
2408
};
2409
ret._setup = function(options) {
2410
if (!compiled) {
2411
compiled = compileInput();
2412
}
2413
return compiled._setup(options);
2414
};
2415
ret._child = function(i, data, blockParams, depths) {
2416
if (!compiled) {
2417
compiled = compileInput();
2418
}
2419
return compiled._child(i, data, blockParams, depths);
2420
};
2421
return ret;
2422
}
2423
2424
__exports__.compile = compile;function argEquals(a, b) {
2425
if (a === b) {
2426
return true;
2427
}
2428
2429
if (isArray(a) && isArray(b) && a.length === b.length) {
2430
for (var i = 0; i < a.length; i++) {
2431
if (!argEquals(a[i], b[i])) {
2432
return false;
2433
}
2434
}
2435
return true;
2436
}
2437
}
2438
2439
function transformLiteralToPath(sexpr) {
2440
if (!sexpr.path.parts) {
2441
var literal = sexpr.path;
2442
// Casting to string here to make false and 0 literal values play nicely with the rest
2443
// of the system.
2444
sexpr.path = new AST.PathExpression(false, 0, [literal.original+''], literal.original+'', literal.log);
2445
}
2446
}
2447
return __exports__;
2448
})(__module4__, __module3__, __module7__);
2449
2450
// handlebars/compiler/code-gen.js
2451
var __module15__ = (function(__dependency1__) {
2452
"use strict";
2453
var __exports__;
2454
var isArray = __dependency1__.isArray;
2455
2456
try {
2457
var SourceMap = require('source-map'),
2458
SourceNode = SourceMap.SourceNode;
2459
} catch (err) {
2460
/* istanbul ignore next: tested but not covered in istanbul due to dist build */
2461
SourceNode = function(line, column, srcFile, chunks) {
2462
this.src = '';
2463
if (chunks) {
2464
this.add(chunks);
2465
}
2466
};
2467
/* istanbul ignore next */
2468
SourceNode.prototype = {
2469
add: function(chunks) {
2470
if (isArray(chunks)) {
2471
chunks = chunks.join('');
2472
}
2473
this.src += chunks;
2474
},
2475
prepend: function(chunks) {
2476
if (isArray(chunks)) {
2477
chunks = chunks.join('');
2478
}
2479
this.src = chunks + this.src;
2480
},
2481
toStringWithSourceMap: function() {
2482
return {code: this.toString()};
2483
},
2484
toString: function() {
2485
return this.src;
2486
}
2487
};
2488
}
2489
2490
2491
function castChunk(chunk, codeGen, loc) {
2492
if (isArray(chunk)) {
2493
var ret = [];
2494
2495
for (var i = 0, len = chunk.length; i < len; i++) {
2496
ret.push(codeGen.wrap(chunk[i], loc));
2497
}
2498
return ret;
2499
} else if (typeof chunk === 'boolean' || typeof chunk === 'number') {
2500
// Handle primitives that the SourceNode will throw up on
2501
return chunk+'';
2502
}
2503
return chunk;
2504
}
2505
2506
2507
function CodeGen(srcFile) {
2508
this.srcFile = srcFile;
2509
this.source = [];
2510
}
2511
2512
CodeGen.prototype = {
2513
prepend: function(source, loc) {
2514
this.source.unshift(this.wrap(source, loc));
2515
},
2516
push: function(source, loc) {
2517
this.source.push(this.wrap(source, loc));
2518
},
2519
2520
merge: function() {
2521
var source = this.empty();
2522
this.each(function(line) {
2523
source.add([' ', line, '\n']);
2524
});
2525
return source;
2526
},
2527
2528
each: function(iter) {
2529
for (var i = 0, len = this.source.length; i < len; i++) {
2530
iter(this.source[i]);
2531
}
2532
},
2533
2534
empty: function(loc) {
2535
loc = loc || this.currentLocation || {start:{}};
2536
return new SourceNode(loc.start.line, loc.start.column, this.srcFile);
2537
},
2538
wrap: function(chunk, loc) {
2539
if (chunk instanceof SourceNode) {
2540
return chunk;
2541
}
2542
2543
loc = loc || this.currentLocation || {start:{}};
2544
chunk = castChunk(chunk, this, loc);
2545
2546
return new SourceNode(loc.start.line, loc.start.column, this.srcFile, chunk);
2547
},
2548
2549
functionCall: function(fn, type, params) {
2550
params = this.generateList(params);
2551
return this.wrap([fn, type ? '.' + type + '(' : '(', params, ')']);
2552
},
2553
2554
quotedString: function(str) {
2555
return '"' + (str + '')
2556
.replace(/\\/g, '\\\\')
2557
.replace(/"/g, '\\"')
2558
.replace(/\n/g, '\\n')
2559
.replace(/\r/g, '\\r')
2560
.replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4
2561
.replace(/\u2029/g, '\\u2029') + '"';
2562
},
2563
2564
objectLiteral: function(obj) {
2565
var pairs = [];
2566
2567
for (var key in obj) {
2568
if (obj.hasOwnProperty(key)) {
2569
var value = castChunk(obj[key], this);
2570
if (value !== 'undefined') {
2571
pairs.push([this.quotedString(key), ':', value]);
2572
}
2573
}
2574
}
2575
2576
var ret = this.generateList(pairs);
2577
ret.prepend('{');
2578
ret.add('}');
2579
return ret;
2580
},
2581
2582
2583
generateList: function(entries, loc) {
2584
var ret = this.empty(loc);
2585
2586
for (var i = 0, len = entries.length; i < len; i++) {
2587
if (i) {
2588
ret.add(',');
2589
}
2590
2591
ret.add(castChunk(entries[i], this, loc));
2592
}
2593
2594
return ret;
2595
},
2596
2597
generateArray: function(entries, loc) {
2598
var ret = this.generateList(entries, loc);
2599
ret.prepend('[');
2600
ret.add(']');
2601
2602
return ret;
2603
}
2604
};
2605
2606
__exports__ = CodeGen;
2607
return __exports__;
2608
})(__module3__);
2609
2610
// handlebars/compiler/javascript-compiler.js
2611
var __module14__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {
2612
"use strict";
2613
var __exports__;
2614
var COMPILER_REVISION = __dependency1__.COMPILER_REVISION;
2615
var REVISION_CHANGES = __dependency1__.REVISION_CHANGES;
2616
var Exception = __dependency2__;
2617
var isArray = __dependency3__.isArray;
2618
var CodeGen = __dependency4__;
2619
2620
function Literal(value) {
2621
this.value = value;
2622
}
2623
2624
function JavaScriptCompiler() {}
2625
2626
JavaScriptCompiler.prototype = {
2627
// PUBLIC API: You can override these methods in a subclass to provide
2628
// alternative compiled forms for name lookup and buffering semantics
2629
nameLookup: function(parent, name /* , type*/) {
2630
if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
2631
return [parent, ".", name];
2632
} else {
2633
return [parent, "['", name, "']"];
2634
}
2635
},
2636
depthedLookup: function(name) {
2637
return [this.aliasable('this.lookup'), '(depths, "', name, '")'];
2638
},
2639
2640
compilerInfo: function() {
2641
var revision = COMPILER_REVISION,
2642
versions = REVISION_CHANGES[revision];
2643
return [revision, versions];
2644
},
2645
2646
appendToBuffer: function(source, location, explicit) {
2647
// Force a source as this simplifies the merge logic.
2648
if (!isArray(source)) {
2649
source = [source];
2650
}
2651
source = this.source.wrap(source, location);
2652
2653
if (this.environment.isSimple) {
2654
return ['return ', source, ';'];
2655
} else if (explicit) {
2656
// This is a case where the buffer operation occurs as a child of another
2657
// construct, generally braces. We have to explicitly output these buffer
2658
// operations to ensure that the emitted code goes in the correct location.
2659
return ['buffer += ', source, ';'];
2660
} else {
2661
source.appendToBuffer = true;
2662
return source;
2663
}
2664
},
2665
2666
initializeBuffer: function() {
2667
return this.quotedString("");
2668
},
2669
// END PUBLIC API
2670
2671
compile: function(environment, options, context, asObject) {
2672
this.environment = environment;
2673
this.options = options;
2674
this.stringParams = this.options.stringParams;
2675
this.trackIds = this.options.trackIds;
2676
this.precompile = !asObject;
2677
2678
this.name = this.environment.name;
2679
this.isChild = !!context;
2680
this.context = context || {
2681
programs: [],
2682
environments: []
2683
};
2684
2685
this.preamble();
2686
2687
this.stackSlot = 0;
2688
this.stackVars = [];
2689
this.aliases = {};
2690
this.registers = { list: [] };
2691
this.hashes = [];
2692
this.compileStack = [];
2693
this.inlineStack = [];
2694
this.blockParams = [];
2695
2696
this.compileChildren(environment, options);
2697
2698
this.useDepths = this.useDepths || environment.useDepths || this.options.compat;
2699
this.useBlockParams = this.useBlockParams || environment.useBlockParams;
2700
2701
var opcodes = environment.opcodes,
2702
opcode,
2703
firstLoc,
2704
i,
2705
l;
2706
2707
for (i = 0, l = opcodes.length; i < l; i++) {
2708
opcode = opcodes[i];
2709
2710
this.source.currentLocation = opcode.loc;
2711
firstLoc = firstLoc || opcode.loc;
2712
this[opcode.opcode].apply(this, opcode.args);
2713
}
2714
2715
// Flush any trailing content that might be pending.
2716
this.source.currentLocation = firstLoc;
2717
this.pushSource('');
2718
2719
/* istanbul ignore next */
2720
if (this.stackSlot || this.inlineStack.length || this.compileStack.length) {
2721
throw new Exception('Compile completed with content left on stack');
2722
}
2723
2724
var fn = this.createFunctionContext(asObject);
2725
if (!this.isChild) {
2726
var ret = {
2727
compiler: this.compilerInfo(),
2728
main: fn
2729
};
2730
var programs = this.context.programs;
2731
for (i = 0, l = programs.length; i < l; i++) {
2732
if (programs[i]) {
2733
ret[i] = programs[i];
2734
}
2735
}
2736
2737
if (this.environment.usePartial) {
2738
ret.usePartial = true;
2739
}
2740
if (this.options.data) {
2741
ret.useData = true;
2742
}
2743
if (this.useDepths) {
2744
ret.useDepths = true;
2745
}
2746
if (this.useBlockParams) {
2747
ret.useBlockParams = true;
2748
}
2749
if (this.options.compat) {
2750
ret.compat = true;
2751
}
2752
2753
if (!asObject) {
2754
ret.compiler = JSON.stringify(ret.compiler);
2755
2756
this.source.currentLocation = {start: {line: 1, column: 0}};
2757
ret = this.objectLiteral(ret);
2758
2759
if (options.srcName) {
2760
ret = ret.toStringWithSourceMap({file: options.destName});
2761
ret.map = ret.map && ret.map.toString();
2762
} else {
2763
ret = ret.toString();
2764
}
2765
} else {
2766
ret.compilerOptions = this.options;
2767
}
2768
2769
return ret;
2770
} else {
2771
return fn;
2772
}
2773
},
2774
2775
preamble: function() {
2776
// track the last context pushed into place to allow skipping the
2777
// getContext opcode when it would be a noop
2778
this.lastContext = 0;
2779
this.source = new CodeGen(this.options.srcName);
2780
},
2781
2782
createFunctionContext: function(asObject) {
2783
var varDeclarations = '';
2784
2785
var locals = this.stackVars.concat(this.registers.list);
2786
if(locals.length > 0) {
2787
varDeclarations += ", " + locals.join(", ");
2788
}
2789
2790
// Generate minimizer alias mappings
2791
//
2792
// When using true SourceNodes, this will update all references to the given alias
2793
// as the source nodes are reused in situ. For the non-source node compilation mode,
2794
// aliases will not be used, but this case is already being run on the client and
2795
// we aren't concern about minimizing the template size.
2796
var aliasCount = 0;
2797
for (var alias in this.aliases) {
2798
var node = this.aliases[alias];
2799
2800
if (this.aliases.hasOwnProperty(alias) && node.children && node.referenceCount > 1) {
2801
varDeclarations += ', alias' + (++aliasCount) + '=' + alias;
2802
node.children[0] = 'alias' + aliasCount;
2803
}
2804
}
2805
2806
var params = ["depth0", "helpers", "partials", "data"];
2807
2808
if (this.useBlockParams || this.useDepths) {
2809
params.push('blockParams');
2810
}
2811
if (this.useDepths) {
2812
params.push('depths');
2813
}
2814
2815
// Perform a second pass over the output to merge content when possible
2816
var source = this.mergeSource(varDeclarations);
2817
2818
if (asObject) {
2819
params.push(source);
2820
2821
return Function.apply(this, params);
2822
} else {
2823
return this.source.wrap(['function(', params.join(','), ') {\n ', source, '}']);
2824
}
2825
},
2826
mergeSource: function(varDeclarations) {
2827
var isSimple = this.environment.isSimple,
2828
appendOnly = !this.forceBuffer,
2829
appendFirst,
2830
2831
sourceSeen,
2832
bufferStart,
2833
bufferEnd;
2834
this.source.each(function(line) {
2835
if (line.appendToBuffer) {
2836
if (bufferStart) {
2837
line.prepend(' + ');
2838
} else {
2839
bufferStart = line;
2840
}
2841
bufferEnd = line;
2842
} else {
2843
if (bufferStart) {
2844
if (!sourceSeen) {
2845
appendFirst = true;
2846
} else {
2847
bufferStart.prepend('buffer += ');
2848
}
2849
bufferEnd.add(';');
2850
bufferStart = bufferEnd = undefined;
2851
}
2852
2853
sourceSeen = true;
2854
if (!isSimple) {
2855
appendOnly = false;
2856
}
2857
}
2858
});
2859
2860
2861
if (appendOnly) {
2862
if (bufferStart) {
2863
bufferStart.prepend('return ');
2864
bufferEnd.add(';');
2865
} else if (!sourceSeen) {
2866
this.source.push('return "";');
2867
}
2868
} else {
2869
varDeclarations += ", buffer = " + (appendFirst ? '' : this.initializeBuffer());
2870
2871
if (bufferStart) {
2872
bufferStart.prepend('return buffer + ');
2873
bufferEnd.add(';');
2874
} else {
2875
this.source.push('return buffer;');
2876
}
2877
}
2878
2879
if (varDeclarations) {
2880
this.source.prepend('var ' + varDeclarations.substring(2) + (appendFirst ? '' : ';\n'));
2881
}
2882
2883
return this.source.merge();
2884
},
2885
2886
// [blockValue]
2887
//
2888
// On stack, before: hash, inverse, program, value
2889
// On stack, after: return value of blockHelperMissing
2890
//
2891
// The purpose of this opcode is to take a block of the form
2892
// `{{#this.foo}}...{{/this.foo}}`, resolve the value of `foo`, and
2893
// replace it on the stack with the result of properly
2894
// invoking blockHelperMissing.
2895
blockValue: function(name) {
2896
var blockHelperMissing = this.aliasable('helpers.blockHelperMissing'),
2897
params = [this.contextName(0)];
2898
this.setupHelperArgs(name, 0, params);
2899
2900
var blockName = this.popStack();
2901
params.splice(1, 0, blockName);
2902
2903
this.push(this.source.functionCall(blockHelperMissing, 'call', params));
2904
},
2905
2906
// [ambiguousBlockValue]
2907
//
2908
// On stack, before: hash, inverse, program, value
2909
// Compiler value, before: lastHelper=value of last found helper, if any
2910
// On stack, after, if no lastHelper: same as [blockValue]
2911
// On stack, after, if lastHelper: value
2912
ambiguousBlockValue: function() {
2913
// We're being a bit cheeky and reusing the options value from the prior exec
2914
var blockHelperMissing = this.aliasable('helpers.blockHelperMissing'),
2915
params = [this.contextName(0)];
2916
this.setupHelperArgs('', 0, params, true);
2917
2918
this.flushInline();
2919
2920
var current = this.topStack();
2921
params.splice(1, 0, current);
2922
2923
this.pushSource([
2924
'if (!', this.lastHelper, ') { ',
2925
current, ' = ', this.source.functionCall(blockHelperMissing, 'call', params),
2926
'}']);
2927
},
2928
2929
// [appendContent]
2930
//
2931
// On stack, before: ...
2932
// On stack, after: ...
2933
//
2934
// Appends the string value of `content` to the current buffer
2935
appendContent: function(content) {
2936
if (this.pendingContent) {
2937
content = this.pendingContent + content;
2938
} else {
2939
this.pendingLocation = this.source.currentLocation;
2940
}
2941
2942
this.pendingContent = content;
2943
},
2944
2945
// [append]
2946
//
2947
// On stack, before: value, ...
2948
// On stack, after: ...
2949
//
2950
// Coerces `value` to a String and appends it to the current buffer.
2951
//
2952
// If `value` is truthy, or 0, it is coerced into a string and appended
2953
// Otherwise, the empty string is appended
2954
append: function() {
2955
if (this.isInline()) {
2956
this.replaceStack(function(current) {
2957
return [' != null ? ', current, ' : ""'];
2958
});
2959
2960
this.pushSource(this.appendToBuffer(this.popStack()));
2961
} else {
2962
var local = this.popStack();
2963
this.pushSource(['if (', local, ' != null) { ', this.appendToBuffer(local, undefined, true), ' }']);
2964
if (this.environment.isSimple) {
2965
this.pushSource(['else { ', this.appendToBuffer("''", undefined, true), ' }']);
2966
}
2967
}
2968
},
2969
2970
// [appendEscaped]
2971
//
2972
// On stack, before: value, ...
2973
// On stack, after: ...
2974
//
2975
// Escape `value` and append it to the buffer
2976
appendEscaped: function() {
2977
this.pushSource(this.appendToBuffer(
2978
[this.aliasable('this.escapeExpression'), '(', this.popStack(), ')']));
2979
},
2980
2981
// [getContext]
2982
//
2983
// On stack, before: ...
2984
// On stack, after: ...
2985
// Compiler value, after: lastContext=depth
2986
//
2987
// Set the value of the `lastContext` compiler value to the depth
2988
getContext: function(depth) {
2989
this.lastContext = depth;
2990
},
2991
2992
// [pushContext]
2993
//
2994
// On stack, before: ...
2995
// On stack, after: currentContext, ...
2996
//
2997
// Pushes the value of the current context onto the stack.
2998
pushContext: function() {
2999
this.pushStackLiteral(this.contextName(this.lastContext));
3000
},
3001
3002
// [lookupOnContext]
3003
//
3004
// On stack, before: ...
3005
// On stack, after: currentContext[name], ...
3006
//
3007
// Looks up the value of `name` on the current context and pushes
3008
// it onto the stack.
3009
lookupOnContext: function(parts, falsy, scoped) {
3010
var i = 0;
3011
3012
if (!scoped && this.options.compat && !this.lastContext) {
3013
// The depthed query is expected to handle the undefined logic for the root level that
3014
// is implemented below, so we evaluate that directly in compat mode
3015
this.push(this.depthedLookup(parts[i++]));
3016
} else {
3017
this.pushContext();
3018
}
3019
3020
this.resolvePath('context', parts, i, falsy);
3021
},
3022
3023
// [lookupBlockParam]
3024
//
3025
// On stack, before: ...
3026
// On stack, after: blockParam[name], ...
3027
//
3028
// Looks up the value of `parts` on the given block param and pushes
3029
// it onto the stack.
3030
lookupBlockParam: function(blockParamId, parts) {
3031
this.useBlockParams = true;
3032
3033
this.push(['blockParams[', blockParamId[0], '][', blockParamId[1], ']']);
3034
this.resolvePath('context', parts, 1);
3035
},
3036
3037
// [lookupData]
3038
//
3039
// On stack, before: ...
3040
// On stack, after: data, ...
3041
//
3042
// Push the data lookup operator
3043
lookupData: function(depth, parts) {
3044
/*jshint -W083 */
3045
if (!depth) {
3046
this.pushStackLiteral('data');
3047
} else {
3048
this.pushStackLiteral('this.data(data, ' + depth + ')');
3049
}
3050
3051
this.resolvePath('data', parts, 0, true);
3052
},
3053
3054
resolvePath: function(type, parts, i, falsy) {
3055
/*jshint -W083 */
3056
if (this.options.strict || this.options.assumeObjects) {
3057
this.push(strictLookup(this.options.strict, this, parts, type));
3058
return;
3059
}
3060
3061
var len = parts.length;
3062
for (; i < len; i++) {
3063
this.replaceStack(function(current) {
3064
var lookup = this.nameLookup(current, parts[i], type);
3065
// We want to ensure that zero and false are handled properly if the context (falsy flag)
3066
// needs to have the special handling for these values.
3067
if (!falsy) {
3068
return [' != null ? ', lookup, ' : ', current];
3069
} else {
3070
// Otherwise we can use generic falsy handling
3071
return [' && ', lookup];
3072
}
3073
});
3074
}
3075
},
3076
3077
// [resolvePossibleLambda]
3078
//
3079
// On stack, before: value, ...
3080
// On stack, after: resolved value, ...
3081
//
3082
// If the `value` is a lambda, replace it on the stack by
3083
// the return value of the lambda
3084
resolvePossibleLambda: function() {
3085
this.push([this.aliasable('this.lambda'), '(', this.popStack(), ', ', this.contextName(0), ')']);
3086
},
3087
3088
// [pushStringParam]
3089
//
3090
// On stack, before: ...
3091
// On stack, after: string, currentContext, ...
3092
//
3093
// This opcode is designed for use in string mode, which
3094
// provides the string value of a parameter along with its
3095
// depth rather than resolving it immediately.
3096
pushStringParam: function(string, type) {
3097
this.pushContext();
3098
this.pushString(type);
3099
3100
// If it's a subexpression, the string result
3101
// will be pushed after this opcode.
3102
if (type !== 'SubExpression') {
3103
if (typeof string === 'string') {
3104
this.pushString(string);
3105
} else {
3106
this.pushStackLiteral(string);
3107
}
3108
}
3109
},
3110
3111
emptyHash: function(omitEmpty) {
3112
if (this.trackIds) {
3113
this.push('{}'); // hashIds
3114
}
3115
if (this.stringParams) {
3116
this.push('{}'); // hashContexts
3117
this.push('{}'); // hashTypes
3118
}
3119
this.pushStackLiteral(omitEmpty ? 'undefined' : '{}');
3120
},
3121
pushHash: function() {
3122
if (this.hash) {
3123
this.hashes.push(this.hash);
3124
}
3125
this.hash = {values: [], types: [], contexts: [], ids: []};
3126
},
3127
popHash: function() {
3128
var hash = this.hash;
3129
this.hash = this.hashes.pop();
3130
3131
if (this.trackIds) {
3132
this.push(this.objectLiteral(hash.ids));
3133
}
3134
if (this.stringParams) {
3135
this.push(this.objectLiteral(hash.contexts));
3136
this.push(this.objectLiteral(hash.types));
3137
}
3138
3139
this.push(this.objectLiteral(hash.values));
3140
},
3141
3142
// [pushString]
3143
//
3144
// On stack, before: ...
3145
// On stack, after: quotedString(string), ...
3146
//
3147
// Push a quoted version of `string` onto the stack
3148
pushString: function(string) {
3149
this.pushStackLiteral(this.quotedString(string));
3150
},
3151
3152
// [pushLiteral]
3153
//
3154
// On stack, before: ...
3155
// On stack, after: value, ...
3156
//
3157
// Pushes a value onto the stack. This operation prevents
3158
// the compiler from creating a temporary variable to hold
3159
// it.
3160
pushLiteral: function(value) {
3161
this.pushStackLiteral(value);
3162
},
3163
3164
// [pushProgram]
3165
//
3166
// On stack, before: ...
3167
// On stack, after: program(guid), ...
3168
//
3169
// Push a program expression onto the stack. This takes
3170
// a compile-time guid and converts it into a runtime-accessible
3171
// expression.
3172
pushProgram: function(guid) {
3173
if (guid != null) {
3174
this.pushStackLiteral(this.programExpression(guid));
3175
} else {
3176
this.pushStackLiteral(null);
3177
}
3178
},
3179
3180
// [invokeHelper]
3181
//
3182
// On stack, before: hash, inverse, program, params..., ...
3183
// On stack, after: result of helper invocation
3184
//
3185
// Pops off the helper's parameters, invokes the helper,
3186
// and pushes the helper's return value onto the stack.
3187
//
3188
// If the helper is not found, `helperMissing` is called.
3189
invokeHelper: function(paramSize, name, isSimple) {
3190
var nonHelper = this.popStack();
3191
var helper = this.setupHelper(paramSize, name);
3192
var simple = isSimple ? [helper.name, ' || '] : '';
3193
3194
var lookup = ['('].concat(simple, nonHelper);
3195
if (!this.options.strict) {
3196
lookup.push(' || ', this.aliasable('helpers.helperMissing'));
3197
}
3198
lookup.push(')');
3199
3200
this.push(this.source.functionCall(lookup, 'call', helper.callParams));
3201
},
3202
3203
// [invokeKnownHelper]
3204
//
3205
// On stack, before: hash, inverse, program, params..., ...
3206
// On stack, after: result of helper invocation
3207
//
3208
// This operation is used when the helper is known to exist,
3209
// so a `helperMissing` fallback is not required.
3210
invokeKnownHelper: function(paramSize, name) {
3211
var helper = this.setupHelper(paramSize, name);
3212
this.push(this.source.functionCall(helper.name, 'call', helper.callParams));
3213
},
3214
3215
// [invokeAmbiguous]
3216
//
3217
// On stack, before: hash, inverse, program, params..., ...
3218
// On stack, after: result of disambiguation
3219
//
3220
// This operation is used when an expression like `{{foo}}`
3221
// is provided, but we don't know at compile-time whether it
3222
// is a helper or a path.
3223
//
3224
// This operation emits more code than the other options,
3225
// and can be avoided by passing the `knownHelpers` and
3226
// `knownHelpersOnly` flags at compile-time.
3227
invokeAmbiguous: function(name, helperCall) {
3228
this.useRegister('helper');
3229
3230
var nonHelper = this.popStack();
3231
3232
this.emptyHash();
3233
var helper = this.setupHelper(0, name, helperCall);
3234
3235
var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper');
3236
3237
var lookup = ['(', '(helper = ', helperName, ' || ', nonHelper, ')'];
3238
if (!this.options.strict) {
3239
lookup[0] = '(helper = ';
3240
lookup.push(
3241
' != null ? helper : ',
3242
this.aliasable('helpers.helperMissing')
3243
);
3244
}
3245
3246
this.push([
3247
'(', lookup,
3248
(helper.paramsInit ? ['),(', helper.paramsInit] : []), '),',
3249
'(typeof helper === ', this.aliasable('"function"'), ' ? ',
3250
this.source.functionCall('helper','call', helper.callParams), ' : helper))'
3251
]);
3252
},
3253
3254
// [invokePartial]
3255
//
3256
// On stack, before: context, ...
3257
// On stack after: result of partial invocation
3258
//
3259
// This operation pops off a context, invokes a partial with that context,
3260
// and pushes the result of the invocation back.
3261
invokePartial: function(isDynamic, name, indent) {
3262
var params = [],
3263
options = this.setupParams(name, 1, params, false);
3264
3265
if (isDynamic) {
3266
name = this.popStack();
3267
delete options.name;
3268
}
3269
3270
if (indent) {
3271
options.indent = JSON.stringify(indent);
3272
}
3273
options.helpers = 'helpers';
3274
options.partials = 'partials';
3275
3276
if (!isDynamic) {
3277
params.unshift(this.nameLookup('partials', name, 'partial'));
3278
} else {
3279
params.unshift(name);
3280
}
3281
3282
if (this.options.compat) {
3283
options.depths = 'depths';
3284
}
3285
options = this.objectLiteral(options);
3286
params.push(options);
3287
3288
this.push(this.source.functionCall('this.invokePartial', '', params));
3289
},
3290
3291
// [assignToHash]
3292
//
3293
// On stack, before: value, ..., hash, ...
3294
// On stack, after: ..., hash, ...
3295
//
3296
// Pops a value off the stack and assigns it to the current hash
3297
assignToHash: function(key) {
3298
var value = this.popStack(),
3299
context,
3300
type,
3301
id;
3302
3303
if (this.trackIds) {
3304
id = this.popStack();
3305
}
3306
if (this.stringParams) {
3307
type = this.popStack();
3308
context = this.popStack();
3309
}
3310
3311
var hash = this.hash;
3312
if (context) {
3313
hash.contexts[key] = context;
3314
}
3315
if (type) {
3316
hash.types[key] = type;
3317
}
3318
if (id) {
3319
hash.ids[key] = id;
3320
}
3321
hash.values[key] = value;
3322
},
3323
3324
pushId: function(type, name, child) {
3325
if (type === 'BlockParam') {
3326
this.pushStackLiteral(
3327
'blockParams[' + name[0] + '].path[' + name[1] + ']'
3328
+ (child ? ' + ' + JSON.stringify('.' + child) : ''));
3329
} else if (type === 'PathExpression') {
3330
this.pushString(name);
3331
} else if (type === 'SubExpression') {
3332
this.pushStackLiteral('true');
3333
} else {
3334
this.pushStackLiteral('null');
3335
}
3336
},
3337
3338
// HELPERS
3339
3340
compiler: JavaScriptCompiler,
3341
3342
compileChildren: function(environment, options) {
3343
var children = environment.children, child, compiler;
3344
3345
for(var i=0, l=children.length; i<l; i++) {
3346
child = children[i];
3347
compiler = new this.compiler();
3348
3349
var index = this.matchExistingProgram(child);
3350
3351
if (index == null) {
3352
this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children
3353
index = this.context.programs.length;
3354
child.index = index;
3355
child.name = 'program' + index;
3356
this.context.programs[index] = compiler.compile(child, options, this.context, !this.precompile);
3357
this.context.environments[index] = child;
3358
3359
this.useDepths = this.useDepths || compiler.useDepths;
3360
this.useBlockParams = this.useBlockParams || compiler.useBlockParams;
3361
} else {
3362
child.index = index;
3363
child.name = 'program' + index;
3364
3365
this.useDepths = this.useDepths || child.useDepths;
3366
this.useBlockParams = this.useBlockParams || child.useBlockParams;
3367
}
3368
}
3369
},
3370
matchExistingProgram: function(child) {
3371
for (var i = 0, len = this.context.environments.length; i < len; i++) {
3372
var environment = this.context.environments[i];
3373
if (environment && environment.equals(child)) {
3374
return i;
3375
}
3376
}
3377
},
3378
3379
programExpression: function(guid) {
3380
var child = this.environment.children[guid],
3381
programParams = [child.index, 'data', child.blockParams];
3382
3383
if (this.useBlockParams || this.useDepths) {
3384
programParams.push('blockParams');
3385
}
3386
if (this.useDepths) {
3387
programParams.push('depths');
3388
}
3389
3390
return 'this.program(' + programParams.join(', ') + ')';
3391
},
3392
3393
useRegister: function(name) {
3394
if(!this.registers[name]) {
3395
this.registers[name] = true;
3396
this.registers.list.push(name);
3397
}
3398
},
3399
3400
push: function(expr) {
3401
if (!(expr instanceof Literal)) {
3402
expr = this.source.wrap(expr);
3403
}
3404
3405
this.inlineStack.push(expr);
3406
return expr;
3407
},
3408
3409
pushStackLiteral: function(item) {
3410
this.push(new Literal(item));
3411
},
3412
3413
pushSource: function(source) {
3414
if (this.pendingContent) {
3415
this.source.push(
3416
this.appendToBuffer(this.source.quotedString(this.pendingContent), this.pendingLocation));
3417
this.pendingContent = undefined;
3418
}
3419
3420
if (source) {
3421
this.source.push(source);
3422
}
3423
},
3424
3425
replaceStack: function(callback) {
3426
var prefix = ['('],
3427
stack,
3428
createdStack,
3429
usedLiteral;
3430
3431
/* istanbul ignore next */
3432
if (!this.isInline()) {
3433
throw new Exception('replaceStack on non-inline');
3434
}
3435
3436
// We want to merge the inline statement into the replacement statement via ','
3437
var top = this.popStack(true);
3438
3439
if (top instanceof Literal) {
3440
// Literals do not need to be inlined
3441
stack = [top.value];
3442
prefix = ['(', stack];
3443
usedLiteral = true;
3444
} else {
3445
// Get or create the current stack name for use by the inline
3446
createdStack = true;
3447
var name = this.incrStack();
3448
3449
prefix = ['((', this.push(name), ' = ', top, ')'];
3450
stack = this.topStack();
3451
}
3452
3453
var item = callback.call(this, stack);
3454
3455
if (!usedLiteral) {
3456
this.popStack();
3457
}
3458
if (createdStack) {
3459
this.stackSlot--;
3460
}
3461
this.push(prefix.concat(item, ')'));
3462
},
3463
3464
incrStack: function() {
3465
this.stackSlot++;
3466
if(this.stackSlot > this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); }
3467
return this.topStackName();
3468
},
3469
topStackName: function() {
3470
return "stack" + this.stackSlot;
3471
},
3472
flushInline: function() {
3473
var inlineStack = this.inlineStack;
3474
this.inlineStack = [];
3475
for (var i = 0, len = inlineStack.length; i < len; i++) {
3476
var entry = inlineStack[i];
3477
/* istanbul ignore if */
3478
if (entry instanceof Literal) {
3479
this.compileStack.push(entry);
3480
} else {
3481
var stack = this.incrStack();
3482
this.pushSource([stack, ' = ', entry, ';']);
3483
this.compileStack.push(stack);
3484
}
3485
}
3486
},
3487
isInline: function() {
3488
return this.inlineStack.length;
3489
},
3490
3491
popStack: function(wrapped) {
3492
var inline = this.isInline(),
3493
item = (inline ? this.inlineStack : this.compileStack).pop();
3494
3495
if (!wrapped && (item instanceof Literal)) {
3496
return item.value;
3497
} else {
3498
if (!inline) {
3499
/* istanbul ignore next */
3500
if (!this.stackSlot) {
3501
throw new Exception('Invalid stack pop');
3502
}
3503
this.stackSlot--;
3504
}
3505
return item;
3506
}
3507
},
3508
3509
topStack: function() {
3510
var stack = (this.isInline() ? this.inlineStack : this.compileStack),
3511
item = stack[stack.length - 1];
3512
3513
/* istanbul ignore if */
3514
if (item instanceof Literal) {
3515
return item.value;
3516
} else {
3517
return item;
3518
}
3519
},
3520
3521
contextName: function(context) {
3522
if (this.useDepths && context) {
3523
return 'depths[' + context + ']';
3524
} else {
3525
return 'depth' + context;
3526
}
3527
},
3528
3529
quotedString: function(str) {
3530
return this.source.quotedString(str);
3531
},
3532
3533
objectLiteral: function(obj) {
3534
return this.source.objectLiteral(obj);
3535
},
3536
3537
aliasable: function(name) {
3538
var ret = this.aliases[name];
3539
if (ret) {
3540
ret.referenceCount++;
3541
return ret;
3542
}
3543
3544
ret = this.aliases[name] = this.source.wrap(name);
3545
ret.aliasable = true;
3546
ret.referenceCount = 1;
3547
3548
return ret;
3549
},
3550
3551
setupHelper: function(paramSize, name, blockHelper) {
3552
var params = [],
3553
paramsInit = this.setupHelperArgs(name, paramSize, params, blockHelper);
3554
var foundHelper = this.nameLookup('helpers', name, 'helper');
3555
3556
return {
3557
params: params,
3558
paramsInit: paramsInit,
3559
name: foundHelper,
3560
callParams: [this.contextName(0)].concat(params)
3561
};
3562
},
3563
3564
setupParams: function(helper, paramSize, params) {
3565
var options = {}, contexts = [], types = [], ids = [], param;
3566
3567
options.name = this.quotedString(helper);
3568
options.hash = this.popStack();
3569
3570
if (this.trackIds) {
3571
options.hashIds = this.popStack();
3572
}
3573
if (this.stringParams) {
3574
options.hashTypes = this.popStack();
3575
options.hashContexts = this.popStack();
3576
}
3577
3578
var inverse = this.popStack(),
3579
program = this.popStack();
3580
3581
// Avoid setting fn and inverse if neither are set. This allows
3582
// helpers to do a check for `if (options.fn)`
3583
if (program || inverse) {
3584
options.fn = program || 'this.noop';
3585
options.inverse = inverse || 'this.noop';
3586
}
3587
3588
// The parameters go on to the stack in order (making sure that they are evaluated in order)
3589
// so we need to pop them off the stack in reverse order
3590
var i = paramSize;
3591
while (i--) {
3592
param = this.popStack();
3593
params[i] = param;
3594
3595
if (this.trackIds) {
3596
ids[i] = this.popStack();
3597
}
3598
if (this.stringParams) {
3599
types[i] = this.popStack();
3600
contexts[i] = this.popStack();
3601
}
3602
}
3603
3604
if (this.trackIds) {
3605
options.ids = this.source.generateArray(ids);
3606
}
3607
if (this.stringParams) {
3608
options.types = this.source.generateArray(types);
3609
options.contexts = this.source.generateArray(contexts);
3610
}
3611
3612
if (this.options.data) {
3613
options.data = 'data';
3614
}
3615
if (this.useBlockParams) {
3616
options.blockParams = 'blockParams';
3617
}
3618
return options;
3619
},
3620
3621
setupHelperArgs: function(helper, paramSize, params, useRegister) {
3622
var options = this.setupParams(helper, paramSize, params, true);
3623
options = this.objectLiteral(options);
3624
if (useRegister) {
3625
this.useRegister('options');
3626
params.push('options');
3627
return ['options=', options];
3628
} else {
3629
params.push(options);
3630
return '';
3631
}
3632
}
3633
};
3634
3635
3636
var reservedWords = (
3637
"break else new var" +
3638
" case finally return void" +
3639
" catch for switch while" +
3640
" continue function this with" +
3641
" default if throw" +
3642
" delete in try" +
3643
" do instanceof typeof" +
3644
" abstract enum int short" +
3645
" boolean export interface static" +
3646
" byte extends long super" +
3647
" char final native synchronized" +
3648
" class float package throws" +
3649
" const goto private transient" +
3650
" debugger implements protected volatile" +
3651
" double import public let yield await" +
3652
" null true false"
3653
).split(" ");
3654
3655
var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
3656
3657
for(var i=0, l=reservedWords.length; i<l; i++) {
3658
compilerWords[reservedWords[i]] = true;
3659
}
3660
3661
JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
3662
return !JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(name);
3663
};
3664
3665
function strictLookup(requireTerminal, compiler, parts, type) {
3666
var stack = compiler.popStack();
3667
3668
var i = 0,
3669
len = parts.length;
3670
if (requireTerminal) {
3671
len--;
3672
}
3673
3674
for (; i < len; i++) {
3675
stack = compiler.nameLookup(stack, parts[i], type);
3676
}
3677
3678
if (requireTerminal) {
3679
return [compiler.aliasable('this.strict'), '(', stack, ', ', compiler.quotedString(parts[i]), ')'];
3680
} else {
3681
return stack;
3682
}
3683
}
3684
3685
__exports__ = JavaScriptCompiler;
3686
return __exports__;
3687
})(__module2__, __module4__, __module3__, __module15__);
3688
3689
// handlebars.js
3690
var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {
3691
"use strict";
3692
var __exports__;
3693
/*globals Handlebars: true */
3694
var Handlebars = __dependency1__;
3695
3696
// Compiler imports
3697
var AST = __dependency2__;
3698
var Parser = __dependency3__.parser;
3699
var parse = __dependency3__.parse;
3700
var Compiler = __dependency4__.Compiler;
3701
var compile = __dependency4__.compile;
3702
var precompile = __dependency4__.precompile;
3703
var JavaScriptCompiler = __dependency5__;
3704
3705
var _create = Handlebars.create;
3706
var create = function() {
3707
var hb = _create();
3708
3709
hb.compile = function(input, options) {
3710
return compile(input, options, hb);
3711
};
3712
hb.precompile = function (input, options) {
3713
return precompile(input, options, hb);
3714
};
3715
3716
hb.AST = AST;
3717
hb.Compiler = Compiler;
3718
hb.JavaScriptCompiler = JavaScriptCompiler;
3719
hb.Parser = Parser;
3720
hb.parse = parse;
3721
3722
return hb;
3723
};
3724
3725
Handlebars = create();
3726
Handlebars.create = create;
3727
3728
/*jshint -W040 */
3729
/* istanbul ignore next */
3730
var root = typeof global !== 'undefined' ? global : window,
3731
$Handlebars = root.Handlebars;
3732
/* istanbul ignore next */
3733
Handlebars.noConflict = function() {
3734
if (root.Handlebars === Handlebars) {
3735
root.Handlebars = $Handlebars;
3736
}
3737
};
3738
3739
Handlebars['default'] = Handlebars;
3740
3741
__exports__ = Handlebars;
3742
return __exports__;
3743
})(__module1__, __module7__, __module8__, __module13__, __module14__);
3744
3745
return __module0__;
3746
}));
3747
3748