handlebars_assets 0.17.2 → 0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/handlebars_assets.gemspec +2 -1
- data/lib/handlebars_assets/version.rb +1 -1
- data/vendor/assets/javascripts/handlebars.js +999 -666
- data/vendor/assets/javascripts/handlebars.runtime.js +219 -89
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edea242129a27984759bac4928647ff0df60bec8
|
4
|
+
data.tar.gz: 2ca19e7c44db381df9e82e1456176e59f5053726
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e6bb55ef61eb4fd6667680ccfa5f0bd2f7b2de5616dabe3740cd6858126b494d32829366b630a3cb989820ef1bd9afebccce5b648833d74d868f7f478bb2f9f
|
7
|
+
data.tar.gz: 92603a8e0458caab9f5069aa049521bd36d64a9f4edf87b640b290774e119ad8dad1b462a2d89a2549fdd75bcbf15aa7d60259ef91a547d86b9dc3772a11594f
|
data/CHANGELOG.md
CHANGED
data/handlebars_assets.gemspec
CHANGED
@@ -6,8 +6,9 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "handlebars_assets"
|
7
7
|
s.version = HandlebarsAssets::VERSION
|
8
8
|
s.authors = ["Les Hill"]
|
9
|
+
s.licenses = ["MIT"]
|
9
10
|
s.email = ["leshill@gmail.com"]
|
10
|
-
s.homepage = ""
|
11
|
+
s.homepage = "https://github.com/leshill/handlebars_assets"
|
11
12
|
s.summary = "Compile Handlebars templates in the Rails asset pipeline."
|
12
13
|
s.description = "Compile Handlebars templates in the Rails asset pipeline."
|
13
14
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/*!
|
2
2
|
|
3
|
-
handlebars
|
3
|
+
handlebars v2.0.0
|
4
4
|
|
5
|
-
Copyright (C) 2011 by Yehuda Katz
|
5
|
+
Copyright (C) 2011-2014 by Yehuda Katz
|
6
6
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -25,7 +25,15 @@ THE SOFTWARE.
|
|
25
25
|
@license
|
26
26
|
*/
|
27
27
|
/* exported Handlebars */
|
28
|
-
|
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 = root.Handlebars || factory();
|
35
|
+
}
|
36
|
+
}(this, function () {
|
29
37
|
// handlebars/safe-string.js
|
30
38
|
var __module4__ = (function() {
|
31
39
|
"use strict";
|
@@ -63,15 +71,19 @@ var __module3__ = (function(__dependency1__) {
|
|
63
71
|
var possible = /[&<>"'`]/;
|
64
72
|
|
65
73
|
function escapeChar(chr) {
|
66
|
-
return escape[chr]
|
74
|
+
return escape[chr];
|
67
75
|
}
|
68
76
|
|
69
|
-
function extend(obj,
|
70
|
-
for(var
|
71
|
-
|
72
|
-
|
77
|
+
function extend(obj /* , ...source */) {
|
78
|
+
for (var i = 1; i < arguments.length; i++) {
|
79
|
+
for (var key in arguments[i]) {
|
80
|
+
if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
|
81
|
+
obj[key] = arguments[i][key];
|
82
|
+
}
|
73
83
|
}
|
74
84
|
}
|
85
|
+
|
86
|
+
return obj;
|
75
87
|
}
|
76
88
|
|
77
89
|
__exports__.extend = extend;var toString = Object.prototype.toString;
|
@@ -82,6 +94,7 @@ var __module3__ = (function(__dependency1__) {
|
|
82
94
|
return typeof value === 'function';
|
83
95
|
};
|
84
96
|
// fallback for older versions of Chrome and Safari
|
97
|
+
/* istanbul ignore next */
|
85
98
|
if (isFunction(/x/)) {
|
86
99
|
isFunction = function(value) {
|
87
100
|
return typeof value === 'function' && toString.call(value) === '[object Function]';
|
@@ -89,6 +102,7 @@ var __module3__ = (function(__dependency1__) {
|
|
89
102
|
}
|
90
103
|
var isFunction;
|
91
104
|
__exports__.isFunction = isFunction;
|
105
|
+
/* istanbul ignore next */
|
92
106
|
var isArray = Array.isArray || function(value) {
|
93
107
|
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
|
94
108
|
};
|
@@ -98,8 +112,10 @@ var __module3__ = (function(__dependency1__) {
|
|
98
112
|
// don't escape SafeStrings, since they're already safe
|
99
113
|
if (string instanceof SafeString) {
|
100
114
|
return string.toString();
|
101
|
-
} else if (
|
115
|
+
} else if (string == null) {
|
102
116
|
return "";
|
117
|
+
} else if (!string) {
|
118
|
+
return string + '';
|
103
119
|
}
|
104
120
|
|
105
121
|
// Force a string conversion as this will be done by the append regardless and
|
@@ -121,7 +137,11 @@ var __module3__ = (function(__dependency1__) {
|
|
121
137
|
}
|
122
138
|
}
|
123
139
|
|
124
|
-
__exports__.isEmpty = isEmpty;
|
140
|
+
__exports__.isEmpty = isEmpty;function appendContextPath(contextPath, id) {
|
141
|
+
return (contextPath ? contextPath + '.' : '') + id;
|
142
|
+
}
|
143
|
+
|
144
|
+
__exports__.appendContextPath = appendContextPath;
|
125
145
|
return __exports__;
|
126
146
|
})(__module4__);
|
127
147
|
|
@@ -166,14 +186,16 @@ var __module2__ = (function(__dependency1__, __dependency2__) {
|
|
166
186
|
var Utils = __dependency1__;
|
167
187
|
var Exception = __dependency2__;
|
168
188
|
|
169
|
-
var VERSION = "
|
170
|
-
__exports__.VERSION = VERSION;var COMPILER_REVISION =
|
189
|
+
var VERSION = "2.0.0";
|
190
|
+
__exports__.VERSION = VERSION;var COMPILER_REVISION = 6;
|
171
191
|
__exports__.COMPILER_REVISION = COMPILER_REVISION;
|
172
192
|
var REVISION_CHANGES = {
|
173
193
|
1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
|
174
194
|
2: '== 1.0.0-rc.3',
|
175
195
|
3: '== 1.0.0-rc.4',
|
176
|
-
4: '
|
196
|
+
4: '== 1.x.x',
|
197
|
+
5: '== 2.0.0-alpha.x',
|
198
|
+
6: '>= 2.0.0-beta.1'
|
177
199
|
};
|
178
200
|
__exports__.REVISION_CHANGES = REVISION_CHANGES;
|
179
201
|
var isArray = Utils.isArray,
|
@@ -194,38 +216,44 @@ var __module2__ = (function(__dependency1__, __dependency2__) {
|
|
194
216
|
logger: logger,
|
195
217
|
log: log,
|
196
218
|
|
197
|
-
registerHelper: function(name, fn
|
219
|
+
registerHelper: function(name, fn) {
|
198
220
|
if (toString.call(name) === objectType) {
|
199
|
-
if (
|
221
|
+
if (fn) { throw new Exception('Arg not supported with multiple helpers'); }
|
200
222
|
Utils.extend(this.helpers, name);
|
201
223
|
} else {
|
202
|
-
if (inverse) { fn.not = inverse; }
|
203
224
|
this.helpers[name] = fn;
|
204
225
|
}
|
205
226
|
},
|
227
|
+
unregisterHelper: function(name) {
|
228
|
+
delete this.helpers[name];
|
229
|
+
},
|
206
230
|
|
207
|
-
registerPartial: function(name,
|
231
|
+
registerPartial: function(name, partial) {
|
208
232
|
if (toString.call(name) === objectType) {
|
209
233
|
Utils.extend(this.partials, name);
|
210
234
|
} else {
|
211
|
-
this.partials[name] =
|
235
|
+
this.partials[name] = partial;
|
212
236
|
}
|
237
|
+
},
|
238
|
+
unregisterPartial: function(name) {
|
239
|
+
delete this.partials[name];
|
213
240
|
}
|
214
241
|
};
|
215
242
|
|
216
243
|
function registerDefaultHelpers(instance) {
|
217
|
-
instance.registerHelper('helperMissing', function(
|
218
|
-
if(arguments.length ===
|
244
|
+
instance.registerHelper('helperMissing', function(/* [args, ]options */) {
|
245
|
+
if(arguments.length === 1) {
|
246
|
+
// A missing field in a {{foo}} constuct.
|
219
247
|
return undefined;
|
220
248
|
} else {
|
221
|
-
|
249
|
+
// Someone is actually trying to call something, blow up.
|
250
|
+
throw new Exception("Missing helper: '" + arguments[arguments.length-1].name + "'");
|
222
251
|
}
|
223
252
|
});
|
224
253
|
|
225
254
|
instance.registerHelper('blockHelperMissing', function(context, options) {
|
226
|
-
var inverse = options.inverse
|
227
|
-
|
228
|
-
if (isFunction(context)) { context = context.call(this); }
|
255
|
+
var inverse = options.inverse,
|
256
|
+
fn = options.fn;
|
229
257
|
|
230
258
|
if(context === true) {
|
231
259
|
return fn(this);
|
@@ -233,19 +261,38 @@ var __module2__ = (function(__dependency1__, __dependency2__) {
|
|
233
261
|
return inverse(this);
|
234
262
|
} else if (isArray(context)) {
|
235
263
|
if(context.length > 0) {
|
264
|
+
if (options.ids) {
|
265
|
+
options.ids = [options.name];
|
266
|
+
}
|
267
|
+
|
236
268
|
return instance.helpers.each(context, options);
|
237
269
|
} else {
|
238
270
|
return inverse(this);
|
239
271
|
}
|
240
272
|
} else {
|
241
|
-
|
273
|
+
if (options.data && options.ids) {
|
274
|
+
var data = createFrame(options.data);
|
275
|
+
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.name);
|
276
|
+
options = {data: data};
|
277
|
+
}
|
278
|
+
|
279
|
+
return fn(context, options);
|
242
280
|
}
|
243
281
|
});
|
244
282
|
|
245
283
|
instance.registerHelper('each', function(context, options) {
|
284
|
+
if (!options) {
|
285
|
+
throw new Exception('Must pass iterator to #each');
|
286
|
+
}
|
287
|
+
|
246
288
|
var fn = options.fn, inverse = options.inverse;
|
247
289
|
var i = 0, ret = "", data;
|
248
290
|
|
291
|
+
var contextPath;
|
292
|
+
if (options.data && options.ids) {
|
293
|
+
contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.';
|
294
|
+
}
|
295
|
+
|
249
296
|
if (isFunction(context)) { context = context.call(this); }
|
250
297
|
|
251
298
|
if (options.data) {
|
@@ -259,16 +306,24 @@ var __module2__ = (function(__dependency1__, __dependency2__) {
|
|
259
306
|
data.index = i;
|
260
307
|
data.first = (i === 0);
|
261
308
|
data.last = (i === (context.length-1));
|
309
|
+
|
310
|
+
if (contextPath) {
|
311
|
+
data.contextPath = contextPath + i;
|
312
|
+
}
|
262
313
|
}
|
263
314
|
ret = ret + fn(context[i], { data: data });
|
264
315
|
}
|
265
316
|
} else {
|
266
317
|
for(var key in context) {
|
267
318
|
if(context.hasOwnProperty(key)) {
|
268
|
-
if(data) {
|
269
|
-
data.key = key;
|
319
|
+
if(data) {
|
320
|
+
data.key = key;
|
270
321
|
data.index = i;
|
271
322
|
data.first = (i === 0);
|
323
|
+
|
324
|
+
if (contextPath) {
|
325
|
+
data.contextPath = contextPath + key;
|
326
|
+
}
|
272
327
|
}
|
273
328
|
ret = ret + fn(context[key], {data: data});
|
274
329
|
i++;
|
@@ -304,12 +359,28 @@ var __module2__ = (function(__dependency1__, __dependency2__) {
|
|
304
359
|
instance.registerHelper('with', function(context, options) {
|
305
360
|
if (isFunction(context)) { context = context.call(this); }
|
306
361
|
|
307
|
-
|
362
|
+
var fn = options.fn;
|
363
|
+
|
364
|
+
if (!Utils.isEmpty(context)) {
|
365
|
+
if (options.data && options.ids) {
|
366
|
+
var data = createFrame(options.data);
|
367
|
+
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]);
|
368
|
+
options = {data:data};
|
369
|
+
}
|
370
|
+
|
371
|
+
return fn(context, options);
|
372
|
+
} else {
|
373
|
+
return options.inverse(this);
|
374
|
+
}
|
308
375
|
});
|
309
376
|
|
310
|
-
instance.registerHelper('log', function(
|
377
|
+
instance.registerHelper('log', function(message, options) {
|
311
378
|
var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
|
312
|
-
instance.log(level,
|
379
|
+
instance.log(level, message);
|
380
|
+
});
|
381
|
+
|
382
|
+
instance.registerHelper('lookup', function(obj, field) {
|
383
|
+
return obj && obj[field];
|
313
384
|
});
|
314
385
|
}
|
315
386
|
|
@@ -324,22 +395,22 @@ var __module2__ = (function(__dependency1__, __dependency2__) {
|
|
324
395
|
level: 3,
|
325
396
|
|
326
397
|
// can be overridden in the host environment
|
327
|
-
log: function(level,
|
398
|
+
log: function(level, message) {
|
328
399
|
if (logger.level <= level) {
|
329
400
|
var method = logger.methodMap[level];
|
330
401
|
if (typeof console !== 'undefined' && console[method]) {
|
331
|
-
console[method].call(console,
|
402
|
+
console[method].call(console, message);
|
332
403
|
}
|
333
404
|
}
|
334
405
|
}
|
335
406
|
};
|
336
407
|
__exports__.logger = logger;
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
var
|
341
|
-
|
342
|
-
return
|
408
|
+
var log = logger.log;
|
409
|
+
__exports__.log = log;
|
410
|
+
var createFrame = function(object) {
|
411
|
+
var frame = Utils.extend({}, object);
|
412
|
+
frame._parent = object;
|
413
|
+
return frame;
|
343
414
|
};
|
344
415
|
__exports__.createFrame = createFrame;
|
345
416
|
return __exports__;
|
@@ -353,6 +424,7 @@ var __module6__ = (function(__dependency1__, __dependency2__, __dependency3__) {
|
|
353
424
|
var Exception = __dependency2__;
|
354
425
|
var COMPILER_REVISION = __dependency3__.COMPILER_REVISION;
|
355
426
|
var REVISION_CHANGES = __dependency3__.REVISION_CHANGES;
|
427
|
+
var createFrame = __dependency3__.createFrame;
|
356
428
|
|
357
429
|
function checkRevision(compilerInfo) {
|
358
430
|
var compilerRevision = compilerInfo && compilerInfo[0] || 1,
|
@@ -375,20 +447,43 @@ var __module6__ = (function(__dependency1__, __dependency2__, __dependency3__) {
|
|
375
447
|
__exports__.checkRevision = checkRevision;// TODO: Remove this line and break up compilePartial
|
376
448
|
|
377
449
|
function template(templateSpec, env) {
|
450
|
+
/* istanbul ignore next */
|
378
451
|
if (!env) {
|
379
452
|
throw new Exception("No environment passed to template");
|
380
453
|
}
|
454
|
+
if (!templateSpec || !templateSpec.main) {
|
455
|
+
throw new Exception('Unknown template object: ' + typeof templateSpec);
|
456
|
+
}
|
381
457
|
|
382
458
|
// Note: Using env.VM references rather than local var references throughout this section to allow
|
383
459
|
// for external users to override these as psuedo-supported APIs.
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
460
|
+
env.VM.checkRevision(templateSpec.compiler);
|
461
|
+
|
462
|
+
var invokePartialWrapper = function(partial, indent, name, context, hash, helpers, partials, data, depths) {
|
463
|
+
if (hash) {
|
464
|
+
context = Utils.extend({}, context, hash);
|
465
|
+
}
|
466
|
+
|
467
|
+
var result = env.VM.invokePartial.call(this, partial, name, context, helpers, partials, data, depths);
|
468
|
+
|
469
|
+
if (result == null && env.compile) {
|
470
|
+
var options = { helpers: helpers, partials: partials, data: data, depths: depths };
|
471
|
+
partials[name] = env.compile(partial, { data: data !== undefined, compat: templateSpec.compat }, env);
|
472
|
+
result = partials[name](context, options);
|
473
|
+
}
|
474
|
+
if (result != null) {
|
475
|
+
if (indent) {
|
476
|
+
var lines = result.split('\n');
|
477
|
+
for (var i = 0, l = lines.length; i < l; i++) {
|
478
|
+
if (!lines[i] && i + 1 === l) {
|
479
|
+
break;
|
480
|
+
}
|
481
|
+
|
482
|
+
lines[i] = indent + lines[i];
|
483
|
+
}
|
484
|
+
result = lines.join('\n');
|
485
|
+
}
|
486
|
+
return result;
|
392
487
|
} else {
|
393
488
|
throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
394
489
|
}
|
@@ -396,84 +491,110 @@ var __module6__ = (function(__dependency1__, __dependency2__, __dependency3__) {
|
|
396
491
|
|
397
492
|
// Just add water
|
398
493
|
var container = {
|
494
|
+
lookup: function(depths, name) {
|
495
|
+
var len = depths.length;
|
496
|
+
for (var i = 0; i < len; i++) {
|
497
|
+
if (depths[i] && depths[i][name] != null) {
|
498
|
+
return depths[i][name];
|
499
|
+
}
|
500
|
+
}
|
501
|
+
},
|
502
|
+
lambda: function(current, context) {
|
503
|
+
return typeof current === 'function' ? current.call(context) : current;
|
504
|
+
},
|
505
|
+
|
399
506
|
escapeExpression: Utils.escapeExpression,
|
400
507
|
invokePartial: invokePartialWrapper,
|
508
|
+
|
509
|
+
fn: function(i) {
|
510
|
+
return templateSpec[i];
|
511
|
+
},
|
512
|
+
|
401
513
|
programs: [],
|
402
|
-
program: function(i,
|
403
|
-
var programWrapper = this.programs[i]
|
404
|
-
|
405
|
-
|
514
|
+
program: function(i, data, depths) {
|
515
|
+
var programWrapper = this.programs[i],
|
516
|
+
fn = this.fn(i);
|
517
|
+
if (data || depths) {
|
518
|
+
programWrapper = program(this, i, fn, data, depths);
|
406
519
|
} else if (!programWrapper) {
|
407
|
-
programWrapper = this.programs[i] = program(i, fn);
|
520
|
+
programWrapper = this.programs[i] = program(this, i, fn);
|
408
521
|
}
|
409
522
|
return programWrapper;
|
410
523
|
},
|
524
|
+
|
525
|
+
data: function(data, depth) {
|
526
|
+
while (data && depth--) {
|
527
|
+
data = data._parent;
|
528
|
+
}
|
529
|
+
return data;
|
530
|
+
},
|
411
531
|
merge: function(param, common) {
|
412
532
|
var ret = param || common;
|
413
533
|
|
414
534
|
if (param && common && (param !== common)) {
|
415
|
-
ret = {};
|
416
|
-
Utils.extend(ret, common);
|
417
|
-
Utils.extend(ret, param);
|
535
|
+
ret = Utils.extend({}, common, param);
|
418
536
|
}
|
537
|
+
|
419
538
|
return ret;
|
420
539
|
},
|
421
|
-
|
540
|
+
|
422
541
|
noop: env.VM.noop,
|
423
|
-
compilerInfo:
|
542
|
+
compilerInfo: templateSpec.compiler
|
424
543
|
};
|
425
544
|
|
426
|
-
|
545
|
+
var ret = function(context, options) {
|
427
546
|
options = options || {};
|
428
|
-
var
|
429
|
-
helpers,
|
430
|
-
partials;
|
547
|
+
var data = options.data;
|
431
548
|
|
432
|
-
|
433
|
-
|
434
|
-
|
549
|
+
ret._setup(options);
|
550
|
+
if (!options.partial && templateSpec.useData) {
|
551
|
+
data = initData(context, data);
|
435
552
|
}
|
436
|
-
var
|
437
|
-
|
438
|
-
|
439
|
-
helpers,
|
440
|
-
partials,
|
441
|
-
options.data);
|
442
|
-
|
443
|
-
if (!options.partial) {
|
444
|
-
env.VM.checkRevision(container.compilerInfo);
|
553
|
+
var depths;
|
554
|
+
if (templateSpec.useDepths) {
|
555
|
+
depths = options.depths ? [context].concat(options.depths) : [context];
|
445
556
|
}
|
446
557
|
|
447
|
-
return
|
558
|
+
return templateSpec.main.call(container, context, container.helpers, container.partials, data, depths);
|
448
559
|
};
|
449
|
-
|
560
|
+
ret.isTop = true;
|
450
561
|
|
451
|
-
|
452
|
-
|
562
|
+
ret._setup = function(options) {
|
563
|
+
if (!options.partial) {
|
564
|
+
container.helpers = container.merge(options.helpers, env.helpers);
|
453
565
|
|
454
|
-
|
455
|
-
|
566
|
+
if (templateSpec.usePartial) {
|
567
|
+
container.partials = container.merge(options.partials, env.partials);
|
568
|
+
}
|
569
|
+
} else {
|
570
|
+
container.helpers = options.helpers;
|
571
|
+
container.partials = options.partials;
|
572
|
+
}
|
573
|
+
};
|
456
574
|
|
457
|
-
|
575
|
+
ret._child = function(i, data, depths) {
|
576
|
+
if (templateSpec.useDepths && !depths) {
|
577
|
+
throw new Exception('must pass parent depths');
|
578
|
+
}
|
579
|
+
|
580
|
+
return program(container, i, templateSpec[i], data, depths);
|
458
581
|
};
|
459
|
-
|
460
|
-
prog.depth = args.length;
|
461
|
-
return prog;
|
582
|
+
return ret;
|
462
583
|
}
|
463
584
|
|
464
|
-
__exports__.
|
585
|
+
__exports__.template = template;function program(container, i, fn, data, depths) {
|
465
586
|
var prog = function(context, options) {
|
466
587
|
options = options || {};
|
467
588
|
|
468
|
-
return fn(context, options.data || data);
|
589
|
+
return fn.call(container, context, container.helpers, container.partials, options.data || data, depths && [context].concat(depths));
|
469
590
|
};
|
470
591
|
prog.program = i;
|
471
|
-
prog.depth = 0;
|
592
|
+
prog.depth = depths ? depths.length : 0;
|
472
593
|
return prog;
|
473
594
|
}
|
474
595
|
|
475
|
-
__exports__.program = program;function invokePartial(partial, name, context, helpers, partials, data) {
|
476
|
-
var options = { partial: true, helpers: helpers, partials: partials, data: data };
|
596
|
+
__exports__.program = program;function invokePartial(partial, name, context, helpers, partials, data, depths) {
|
597
|
+
var options = { partial: true, helpers: helpers, partials: partials, data: data, depths: depths };
|
477
598
|
|
478
599
|
if(partial === undefined) {
|
479
600
|
throw new Exception("The partial " + name + " could not be found");
|
@@ -484,7 +605,13 @@ var __module6__ = (function(__dependency1__, __dependency2__, __dependency3__) {
|
|
484
605
|
|
485
606
|
__exports__.invokePartial = invokePartial;function noop() { return ""; }
|
486
607
|
|
487
|
-
__exports__.noop = noop;
|
608
|
+
__exports__.noop = noop;function initData(context, data) {
|
609
|
+
if (!data || !('root' in data)) {
|
610
|
+
data = data ? createFrame(data) : {};
|
611
|
+
data.root = context;
|
612
|
+
}
|
613
|
+
return data;
|
614
|
+
}
|
488
615
|
return __exports__;
|
489
616
|
})(__module3__, __module5__, __module2__);
|
490
617
|
|
@@ -510,6 +637,7 @@ var __module1__ = (function(__dependency1__, __dependency2__, __dependency3__, _
|
|
510
637
|
hb.SafeString = SafeString;
|
511
638
|
hb.Exception = Exception;
|
512
639
|
hb.Utils = Utils;
|
640
|
+
hb.escapeExpression = Utils.escapeExpression;
|
513
641
|
|
514
642
|
hb.VM = runtime;
|
515
643
|
hb.template = function(spec) {
|
@@ -522,6 +650,8 @@ var __module1__ = (function(__dependency1__, __dependency2__, __dependency3__, _
|
|
522
650
|
var Handlebars = create();
|
523
651
|
Handlebars.create = create;
|
524
652
|
|
653
|
+
Handlebars['default'] = Handlebars;
|
654
|
+
|
525
655
|
__exports__ = Handlebars;
|
526
656
|
return __exports__;
|
527
657
|
})(__module2__, __module4__, __module5__, __module3__, __module6__);
|
@@ -532,7 +662,7 @@ var __module7__ = (function(__dependency1__) {
|
|
532
662
|
var __exports__;
|
533
663
|
var Exception = __dependency1__;
|
534
664
|
|
535
|
-
function LocationInfo(locInfo){
|
665
|
+
function LocationInfo(locInfo) {
|
536
666
|
locInfo = locInfo || {};
|
537
667
|
this.firstLine = locInfo.first_line;
|
538
668
|
this.firstColumn = locInfo.first_column;
|
@@ -541,38 +671,11 @@ var __module7__ = (function(__dependency1__) {
|
|
541
671
|
}
|
542
672
|
|
543
673
|
var AST = {
|
544
|
-
ProgramNode: function(statements,
|
545
|
-
var inverseLocationInfo, firstInverseNode;
|
546
|
-
if (arguments.length === 3) {
|
547
|
-
locInfo = inverse;
|
548
|
-
inverse = null;
|
549
|
-
} else if (arguments.length === 2) {
|
550
|
-
locInfo = inverseStrip;
|
551
|
-
inverseStrip = null;
|
552
|
-
}
|
553
|
-
|
674
|
+
ProgramNode: function(statements, strip, locInfo) {
|
554
675
|
LocationInfo.call(this, locInfo);
|
555
676
|
this.type = "program";
|
556
677
|
this.statements = statements;
|
557
|
-
this.strip =
|
558
|
-
|
559
|
-
if(inverse) {
|
560
|
-
firstInverseNode = inverse[0];
|
561
|
-
if (firstInverseNode) {
|
562
|
-
inverseLocationInfo = {
|
563
|
-
first_line: firstInverseNode.firstLine,
|
564
|
-
last_line: firstInverseNode.lastLine,
|
565
|
-
last_column: firstInverseNode.lastColumn,
|
566
|
-
first_column: firstInverseNode.firstColumn
|
567
|
-
};
|
568
|
-
this.inverse = new AST.ProgramNode(inverse, inverseStrip, inverseLocationInfo);
|
569
|
-
} else {
|
570
|
-
this.inverse = new AST.ProgramNode(inverse, inverseStrip);
|
571
|
-
}
|
572
|
-
this.strip.right = inverseStrip.left;
|
573
|
-
} else if (inverseStrip) {
|
574
|
-
this.strip.left = inverseStrip.right;
|
575
|
-
}
|
678
|
+
this.strip = strip;
|
576
679
|
},
|
577
680
|
|
578
681
|
MustacheNode: function(rawParams, hash, open, strip, locInfo) {
|
@@ -596,8 +699,6 @@ var __module7__ = (function(__dependency1__) {
|
|
596
699
|
this.sexpr = new AST.SexprNode(rawParams, hash);
|
597
700
|
}
|
598
701
|
|
599
|
-
this.sexpr.isRoot = true;
|
600
|
-
|
601
702
|
// Support old AST API that stored this info in MustacheNode
|
602
703
|
this.id = this.sexpr.id;
|
603
704
|
this.params = this.sexpr.params;
|
@@ -615,57 +716,63 @@ var __module7__ = (function(__dependency1__) {
|
|
615
716
|
var id = this.id = rawParams[0];
|
616
717
|
var params = this.params = rawParams.slice(1);
|
617
718
|
|
618
|
-
// a mustache is an eligible helper if:
|
619
|
-
// * its id is simple (a single part, not `this` or `..`)
|
620
|
-
var eligibleHelper = this.eligibleHelper = id.isSimple;
|
621
|
-
|
622
719
|
// a mustache is definitely a helper if:
|
623
720
|
// * it is an eligible helper, and
|
624
721
|
// * it has at least one parameter or hash segment
|
625
|
-
this.isHelper =
|
722
|
+
this.isHelper = !!(params.length || hash);
|
723
|
+
|
724
|
+
// a mustache is an eligible helper if:
|
725
|
+
// * its id is simple (a single part, not `this` or `..`)
|
726
|
+
this.eligibleHelper = this.isHelper || id.isSimple;
|
626
727
|
|
627
728
|
// if a mustache is an eligible helper but not a definite
|
628
729
|
// helper, it is ambiguous, and will be resolved in a later
|
629
730
|
// pass or at runtime.
|
630
731
|
},
|
631
732
|
|
632
|
-
PartialNode: function(partialName, context, strip, locInfo) {
|
733
|
+
PartialNode: function(partialName, context, hash, strip, locInfo) {
|
633
734
|
LocationInfo.call(this, locInfo);
|
634
735
|
this.type = "partial";
|
635
736
|
this.partialName = partialName;
|
636
737
|
this.context = context;
|
738
|
+
this.hash = hash;
|
637
739
|
this.strip = strip;
|
740
|
+
|
741
|
+
this.strip.inlineStandalone = true;
|
638
742
|
},
|
639
743
|
|
640
|
-
BlockNode: function(mustache, program, inverse,
|
744
|
+
BlockNode: function(mustache, program, inverse, strip, locInfo) {
|
641
745
|
LocationInfo.call(this, locInfo);
|
642
746
|
|
643
|
-
if(mustache.sexpr.id.original !== close.path.original) {
|
644
|
-
throw new Exception(mustache.sexpr.id.original + " doesn't match " + close.path.original, this);
|
645
|
-
}
|
646
|
-
|
647
747
|
this.type = 'block';
|
648
748
|
this.mustache = mustache;
|
649
749
|
this.program = program;
|
650
750
|
this.inverse = inverse;
|
651
|
-
|
652
|
-
this.strip = {
|
653
|
-
left: mustache.strip.left,
|
654
|
-
right: close.strip.right
|
655
|
-
};
|
656
|
-
|
657
|
-
(program || inverse).strip.left = mustache.strip.right;
|
658
|
-
(inverse || program).strip.right = close.strip.left;
|
751
|
+
this.strip = strip;
|
659
752
|
|
660
753
|
if (inverse && !program) {
|
661
754
|
this.isInverse = true;
|
662
755
|
}
|
663
756
|
},
|
664
757
|
|
758
|
+
RawBlockNode: function(mustache, content, close, locInfo) {
|
759
|
+
LocationInfo.call(this, locInfo);
|
760
|
+
|
761
|
+
if (mustache.sexpr.id.original !== close) {
|
762
|
+
throw new Exception(mustache.sexpr.id.original + " doesn't match " + close, this);
|
763
|
+
}
|
764
|
+
|
765
|
+
content = new AST.ContentNode(content, locInfo);
|
766
|
+
|
767
|
+
this.type = 'block';
|
768
|
+
this.mustache = mustache;
|
769
|
+
this.program = new AST.ProgramNode([content], {}, locInfo);
|
770
|
+
},
|
771
|
+
|
665
772
|
ContentNode: function(string, locInfo) {
|
666
773
|
LocationInfo.call(this, locInfo);
|
667
774
|
this.type = "content";
|
668
|
-
this.string = string;
|
775
|
+
this.original = this.string = string;
|
669
776
|
},
|
670
777
|
|
671
778
|
HashNode: function(pairs, locInfo) {
|
@@ -680,7 +787,8 @@ var __module7__ = (function(__dependency1__) {
|
|
680
787
|
|
681
788
|
var original = "",
|
682
789
|
dig = [],
|
683
|
-
depth = 0
|
790
|
+
depth = 0,
|
791
|
+
depthString = '';
|
684
792
|
|
685
793
|
for(var i=0,l=parts.length; i<l; i++) {
|
686
794
|
var part = parts[i].part;
|
@@ -691,6 +799,7 @@ var __module7__ = (function(__dependency1__) {
|
|
691
799
|
throw new Exception("Invalid path: " + original, this);
|
692
800
|
} else if (part === "..") {
|
693
801
|
depth++;
|
802
|
+
depthString += '../';
|
694
803
|
} else {
|
695
804
|
this.isScoped = true;
|
696
805
|
}
|
@@ -703,6 +812,7 @@ var __module7__ = (function(__dependency1__) {
|
|
703
812
|
this.parts = dig;
|
704
813
|
this.string = dig.join('.');
|
705
814
|
this.depth = depth;
|
815
|
+
this.idName = depthString + this.string;
|
706
816
|
|
707
817
|
// an ID is simple if it only has one part, and that part is not
|
708
818
|
// `..` or `this`.
|
@@ -721,6 +831,8 @@ var __module7__ = (function(__dependency1__) {
|
|
721
831
|
LocationInfo.call(this, locInfo);
|
722
832
|
this.type = "DATA";
|
723
833
|
this.id = id;
|
834
|
+
this.stringModeValue = id.stringModeValue;
|
835
|
+
this.idName = '@' + id.stringModeValue;
|
724
836
|
},
|
725
837
|
|
726
838
|
StringNode: function(string, locInfo) {
|
@@ -731,12 +843,12 @@ var __module7__ = (function(__dependency1__) {
|
|
731
843
|
this.stringModeValue = string;
|
732
844
|
},
|
733
845
|
|
734
|
-
|
846
|
+
NumberNode: function(number, locInfo) {
|
735
847
|
LocationInfo.call(this, locInfo);
|
736
|
-
this.type = "
|
848
|
+
this.type = "NUMBER";
|
737
849
|
this.original =
|
738
|
-
this.
|
739
|
-
this.stringModeValue = Number(
|
850
|
+
this.number = number;
|
851
|
+
this.stringModeValue = Number(number);
|
740
852
|
},
|
741
853
|
|
742
854
|
BooleanNode: function(bool, locInfo) {
|
@@ -750,9 +862,14 @@ var __module7__ = (function(__dependency1__) {
|
|
750
862
|
LocationInfo.call(this, locInfo);
|
751
863
|
this.type = "comment";
|
752
864
|
this.comment = comment;
|
865
|
+
|
866
|
+
this.strip = {
|
867
|
+
inlineStandalone: true
|
868
|
+
};
|
753
869
|
}
|
754
870
|
};
|
755
871
|
|
872
|
+
|
756
873
|
// Must be exported as an object rather than the root of the module as the jison lexer
|
757
874
|
// most modify the object to operate properly.
|
758
875
|
__exports__ = AST;
|
@@ -764,109 +881,108 @@ var __module9__ = (function() {
|
|
764
881
|
"use strict";
|
765
882
|
var __exports__;
|
766
883
|
/* jshint ignore:start */
|
884
|
+
/* istanbul ignore next */
|
767
885
|
/* Jison generated parser */
|
768
886
|
var handlebars = (function(){
|
769
887
|
var parser = {trace: function trace() { },
|
770
888
|
yy: {},
|
771
|
-
symbols_: {"error":2,"root":3,"
|
772
|
-
terminals_: {2:"error",5:"EOF",
|
773
|
-
productions_: [0,[3,2],[
|
889
|
+
symbols_: {"error":2,"root":3,"program":4,"EOF":5,"program_repetition0":6,"statement":7,"mustache":8,"block":9,"rawBlock":10,"partial":11,"CONTENT":12,"COMMENT":13,"openRawBlock":14,"END_RAW_BLOCK":15,"OPEN_RAW_BLOCK":16,"sexpr":17,"CLOSE_RAW_BLOCK":18,"openBlock":19,"block_option0":20,"closeBlock":21,"openInverse":22,"block_option1":23,"OPEN_BLOCK":24,"CLOSE":25,"OPEN_INVERSE":26,"inverseAndProgram":27,"INVERSE":28,"OPEN_ENDBLOCK":29,"path":30,"OPEN":31,"OPEN_UNESCAPED":32,"CLOSE_UNESCAPED":33,"OPEN_PARTIAL":34,"partialName":35,"param":36,"partial_option0":37,"partial_option1":38,"sexpr_repetition0":39,"sexpr_option0":40,"dataName":41,"STRING":42,"NUMBER":43,"BOOLEAN":44,"OPEN_SEXPR":45,"CLOSE_SEXPR":46,"hash":47,"hash_repetition_plus0":48,"hashSegment":49,"ID":50,"EQUALS":51,"DATA":52,"pathSegments":53,"SEP":54,"$accept":0,"$end":1},
|
890
|
+
terminals_: {2:"error",5:"EOF",12:"CONTENT",13:"COMMENT",15:"END_RAW_BLOCK",16:"OPEN_RAW_BLOCK",18:"CLOSE_RAW_BLOCK",24:"OPEN_BLOCK",25:"CLOSE",26:"OPEN_INVERSE",28:"INVERSE",29:"OPEN_ENDBLOCK",31:"OPEN",32:"OPEN_UNESCAPED",33:"CLOSE_UNESCAPED",34:"OPEN_PARTIAL",42:"STRING",43:"NUMBER",44:"BOOLEAN",45:"OPEN_SEXPR",46:"CLOSE_SEXPR",50:"ID",51:"EQUALS",52:"DATA",54:"SEP"},
|
891
|
+
productions_: [0,[3,2],[4,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[10,3],[14,3],[9,4],[9,4],[19,3],[22,3],[27,2],[21,3],[8,3],[8,3],[11,5],[11,4],[17,3],[17,1],[36,1],[36,1],[36,1],[36,1],[36,1],[36,3],[47,1],[49,3],[35,1],[35,1],[35,1],[41,2],[30,1],[53,3],[53,1],[6,0],[6,2],[20,0],[20,1],[23,0],[23,1],[37,0],[37,1],[38,0],[38,1],[39,0],[39,2],[40,0],[40,1],[48,1],[48,2]],
|
774
892
|
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
|
775
893
|
|
776
894
|
var $0 = $$.length - 1;
|
777
895
|
switch (yystate) {
|
778
|
-
case 1:
|
779
|
-
break;
|
780
|
-
case 2: return new yy.ProgramNode([], this._$);
|
896
|
+
case 1: yy.prepareProgram($$[$0-1].statements, true); return $$[$0-1];
|
781
897
|
break;
|
782
|
-
case
|
898
|
+
case 2:this.$ = new yy.ProgramNode(yy.prepareProgram($$[$0]), {}, this._$);
|
783
899
|
break;
|
784
|
-
case
|
900
|
+
case 3:this.$ = $$[$0];
|
785
901
|
break;
|
786
|
-
case
|
902
|
+
case 4:this.$ = $$[$0];
|
787
903
|
break;
|
788
|
-
case
|
904
|
+
case 5:this.$ = $$[$0];
|
789
905
|
break;
|
790
|
-
case
|
906
|
+
case 6:this.$ = $$[$0];
|
791
907
|
break;
|
792
|
-
case
|
908
|
+
case 7:this.$ = new yy.ContentNode($$[$0], this._$);
|
793
909
|
break;
|
794
|
-
case
|
910
|
+
case 8:this.$ = new yy.CommentNode($$[$0], this._$);
|
795
911
|
break;
|
796
|
-
case
|
912
|
+
case 9:this.$ = new yy.RawBlockNode($$[$0-2], $$[$0-1], $$[$0], this._$);
|
797
913
|
break;
|
798
|
-
case
|
914
|
+
case 10:this.$ = new yy.MustacheNode($$[$0-1], null, '', '', this._$);
|
799
915
|
break;
|
800
|
-
case
|
916
|
+
case 11:this.$ = yy.prepareBlock($$[$0-3], $$[$0-2], $$[$0-1], $$[$0], false, this._$);
|
801
917
|
break;
|
802
|
-
case
|
918
|
+
case 12:this.$ = yy.prepareBlock($$[$0-3], $$[$0-2], $$[$0-1], $$[$0], true, this._$);
|
803
919
|
break;
|
804
|
-
case
|
920
|
+
case 13:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$);
|
805
921
|
break;
|
806
|
-
case
|
922
|
+
case 14:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$);
|
807
923
|
break;
|
808
|
-
case
|
924
|
+
case 15:this.$ = { strip: yy.stripFlags($$[$0-1], $$[$0-1]), program: $$[$0] };
|
809
925
|
break;
|
810
|
-
case
|
926
|
+
case 16:this.$ = {path: $$[$0-1], strip: yy.stripFlags($$[$0-2], $$[$0])};
|
811
927
|
break;
|
812
|
-
case
|
928
|
+
case 17:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$);
|
813
929
|
break;
|
814
|
-
case
|
930
|
+
case 18:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], yy.stripFlags($$[$0-2], $$[$0]), this._$);
|
815
931
|
break;
|
816
|
-
case
|
932
|
+
case 19:this.$ = new yy.PartialNode($$[$0-3], $$[$0-2], $$[$0-1], yy.stripFlags($$[$0-4], $$[$0]), this._$);
|
817
933
|
break;
|
818
|
-
case
|
934
|
+
case 20:this.$ = new yy.PartialNode($$[$0-2], undefined, $$[$0-1], yy.stripFlags($$[$0-3], $$[$0]), this._$);
|
819
935
|
break;
|
820
|
-
case
|
936
|
+
case 21:this.$ = new yy.SexprNode([$$[$0-2]].concat($$[$0-1]), $$[$0], this._$);
|
821
937
|
break;
|
822
|
-
case
|
938
|
+
case 22:this.$ = new yy.SexprNode([$$[$0]], null, this._$);
|
823
939
|
break;
|
824
|
-
case
|
940
|
+
case 23:this.$ = $$[$0];
|
825
941
|
break;
|
826
|
-
case
|
942
|
+
case 24:this.$ = new yy.StringNode($$[$0], this._$);
|
827
943
|
break;
|
828
|
-
case
|
944
|
+
case 25:this.$ = new yy.NumberNode($$[$0], this._$);
|
829
945
|
break;
|
830
|
-
case
|
946
|
+
case 26:this.$ = new yy.BooleanNode($$[$0], this._$);
|
831
947
|
break;
|
832
|
-
case
|
948
|
+
case 27:this.$ = $$[$0];
|
833
949
|
break;
|
834
|
-
case
|
950
|
+
case 28:$$[$0-1].isHelper = true; this.$ = $$[$0-1];
|
835
951
|
break;
|
836
|
-
case
|
952
|
+
case 29:this.$ = new yy.HashNode($$[$0], this._$);
|
837
953
|
break;
|
838
|
-
case
|
954
|
+
case 30:this.$ = [$$[$0-2], $$[$0]];
|
839
955
|
break;
|
840
|
-
case
|
956
|
+
case 31:this.$ = new yy.PartialNameNode($$[$0], this._$);
|
841
957
|
break;
|
842
|
-
case
|
958
|
+
case 32:this.$ = new yy.PartialNameNode(new yy.StringNode($$[$0], this._$), this._$);
|
843
959
|
break;
|
844
|
-
case
|
960
|
+
case 33:this.$ = new yy.PartialNameNode(new yy.NumberNode($$[$0], this._$));
|
845
961
|
break;
|
846
|
-
case
|
962
|
+
case 34:this.$ = new yy.DataNode($$[$0], this._$);
|
847
963
|
break;
|
848
|
-
case
|
964
|
+
case 35:this.$ = new yy.IdNode($$[$0], this._$);
|
849
965
|
break;
|
850
|
-
case
|
966
|
+
case 36: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2];
|
851
967
|
break;
|
852
|
-
case
|
968
|
+
case 37:this.$ = [{part: $$[$0]}];
|
853
969
|
break;
|
854
|
-
case
|
970
|
+
case 38:this.$ = [];
|
855
971
|
break;
|
856
|
-
case
|
972
|
+
case 39:$$[$0-1].push($$[$0]);
|
857
973
|
break;
|
858
|
-
case
|
974
|
+
case 48:this.$ = [];
|
859
975
|
break;
|
860
|
-
case
|
976
|
+
case 49:$$[$0-1].push($$[$0]);
|
861
977
|
break;
|
862
|
-
case
|
978
|
+
case 52:this.$ = [$$[$0]];
|
863
979
|
break;
|
864
|
-
case
|
980
|
+
case 53:$$[$0-1].push($$[$0]);
|
865
981
|
break;
|
866
982
|
}
|
867
983
|
},
|
868
|
-
table: [{3:1,4:2,5:[
|
869
|
-
defaultActions: {
|
984
|
+
table: [{3:1,4:2,5:[2,38],6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],31:[2,38],32:[2,38],34:[2,38]},{1:[3]},{5:[1,4]},{5:[2,2],7:5,8:6,9:7,10:8,11:9,12:[1,10],13:[1,11],14:16,16:[1,20],19:14,22:15,24:[1,18],26:[1,19],28:[2,2],29:[2,2],31:[1,12],32:[1,13],34:[1,17]},{1:[2,1]},{5:[2,39],12:[2,39],13:[2,39],16:[2,39],24:[2,39],26:[2,39],28:[2,39],29:[2,39],31:[2,39],32:[2,39],34:[2,39]},{5:[2,3],12:[2,3],13:[2,3],16:[2,3],24:[2,3],26:[2,3],28:[2,3],29:[2,3],31:[2,3],32:[2,3],34:[2,3]},{5:[2,4],12:[2,4],13:[2,4],16:[2,4],24:[2,4],26:[2,4],28:[2,4],29:[2,4],31:[2,4],32:[2,4],34:[2,4]},{5:[2,5],12:[2,5],13:[2,5],16:[2,5],24:[2,5],26:[2,5],28:[2,5],29:[2,5],31:[2,5],32:[2,5],34:[2,5]},{5:[2,6],12:[2,6],13:[2,6],16:[2,6],24:[2,6],26:[2,6],28:[2,6],29:[2,6],31:[2,6],32:[2,6],34:[2,6]},{5:[2,7],12:[2,7],13:[2,7],16:[2,7],24:[2,7],26:[2,7],28:[2,7],29:[2,7],31:[2,7],32:[2,7],34:[2,7]},{5:[2,8],12:[2,8],13:[2,8],16:[2,8],24:[2,8],26:[2,8],28:[2,8],29:[2,8],31:[2,8],32:[2,8],34:[2,8]},{17:21,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:27,30:22,41:23,50:[1,26],52:[1,25],53:24},{4:28,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],28:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{4:29,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],28:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{12:[1,30]},{30:32,35:31,42:[1,33],43:[1,34],50:[1,26],53:24},{17:35,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:36,30:22,41:23,50:[1,26],52:[1,25],53:24},{17:37,30:22,41:23,50:[1,26],52:[1,25],53:24},{25:[1,38]},{18:[2,48],25:[2,48],33:[2,48],39:39,42:[2,48],43:[2,48],44:[2,48],45:[2,48],46:[2,48],50:[2,48],52:[2,48]},{18:[2,22],25:[2,22],33:[2,22],46:[2,22]},{18:[2,35],25:[2,35],33:[2,35],42:[2,35],43:[2,35],44:[2,35],45:[2,35],46:[2,35],50:[2,35],52:[2,35],54:[1,40]},{30:41,50:[1,26],53:24},{18:[2,37],25:[2,37],33:[2,37],42:[2,37],43:[2,37],44:[2,37],45:[2,37],46:[2,37],50:[2,37],52:[2,37],54:[2,37]},{33:[1,42]},{20:43,27:44,28:[1,45],29:[2,40]},{23:46,27:47,28:[1,45],29:[2,42]},{15:[1,48]},{25:[2,46],30:51,36:49,38:50,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],47:57,48:58,49:60,50:[1,59],52:[1,25],53:24},{25:[2,31],42:[2,31],43:[2,31],44:[2,31],45:[2,31],50:[2,31],52:[2,31]},{25:[2,32],42:[2,32],43:[2,32],44:[2,32],45:[2,32],50:[2,32],52:[2,32]},{25:[2,33],42:[2,33],43:[2,33],44:[2,33],45:[2,33],50:[2,33],52:[2,33]},{25:[1,61]},{25:[1,62]},{18:[1,63]},{5:[2,17],12:[2,17],13:[2,17],16:[2,17],24:[2,17],26:[2,17],28:[2,17],29:[2,17],31:[2,17],32:[2,17],34:[2,17]},{18:[2,50],25:[2,50],30:51,33:[2,50],36:65,40:64,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],46:[2,50],47:66,48:58,49:60,50:[1,59],52:[1,25],53:24},{50:[1,67]},{18:[2,34],25:[2,34],33:[2,34],42:[2,34],43:[2,34],44:[2,34],45:[2,34],46:[2,34],50:[2,34],52:[2,34]},{5:[2,18],12:[2,18],13:[2,18],16:[2,18],24:[2,18],26:[2,18],28:[2,18],29:[2,18],31:[2,18],32:[2,18],34:[2,18]},{21:68,29:[1,69]},{29:[2,41]},{4:70,6:3,12:[2,38],13:[2,38],16:[2,38],24:[2,38],26:[2,38],29:[2,38],31:[2,38],32:[2,38],34:[2,38]},{21:71,29:[1,69]},{29:[2,43]},{5:[2,9],12:[2,9],13:[2,9],16:[2,9],24:[2,9],26:[2,9],28:[2,9],29:[2,9],31:[2,9],32:[2,9],34:[2,9]},{25:[2,44],37:72,47:73,48:58,49:60,50:[1,74]},{25:[1,75]},{18:[2,23],25:[2,23],33:[2,23],42:[2,23],43:[2,23],44:[2,23],45:[2,23],46:[2,23],50:[2,23],52:[2,23]},{18:[2,24],25:[2,24],33:[2,24],42:[2,24],43:[2,24],44:[2,24],45:[2,24],46:[2,24],50:[2,24],52:[2,24]},{18:[2,25],25:[2,25],33:[2,25],42:[2,25],43:[2,25],44:[2,25],45:[2,25],46:[2,25],50:[2,25],52:[2,25]},{18:[2,26],25:[2,26],33:[2,26],42:[2,26],43:[2,26],44:[2,26],45:[2,26],46:[2,26],50:[2,26],52:[2,26]},{18:[2,27],25:[2,27],33:[2,27],42:[2,27],43:[2,27],44:[2,27],45:[2,27],46:[2,27],50:[2,27],52:[2,27]},{17:76,30:22,41:23,50:[1,26],52:[1,25],53:24},{25:[2,47]},{18:[2,29],25:[2,29],33:[2,29],46:[2,29],49:77,50:[1,74]},{18:[2,37],25:[2,37],33:[2,37],42:[2,37],43:[2,37],44:[2,37],45:[2,37],46:[2,37],50:[2,37],51:[1,78],52:[2,37],54:[2,37]},{18:[2,52],25:[2,52],33:[2,52],46:[2,52],50:[2,52]},{12:[2,13],13:[2,13],16:[2,13],24:[2,13],26:[2,13],28:[2,13],29:[2,13],31:[2,13],32:[2,13],34:[2,13]},{12:[2,14],13:[2,14],16:[2,14],24:[2,14],26:[2,14],28:[2,14],29:[2,14],31:[2,14],32:[2,14],34:[2,14]},{12:[2,10]},{18:[2,21],25:[2,21],33:[2,21],46:[2,21]},{18:[2,49],25:[2,49],33:[2,49],42:[2,49],43:[2,49],44:[2,49],45:[2,49],46:[2,49],50:[2,49],52:[2,49]},{18:[2,51],25:[2,51],33:[2,51],46:[2,51]},{18:[2,36],25:[2,36],33:[2,36],42:[2,36],43:[2,36],44:[2,36],45:[2,36],46:[2,36],50:[2,36],52:[2,36],54:[2,36]},{5:[2,11],12:[2,11],13:[2,11],16:[2,11],24:[2,11],26:[2,11],28:[2,11],29:[2,11],31:[2,11],32:[2,11],34:[2,11]},{30:79,50:[1,26],53:24},{29:[2,15]},{5:[2,12],12:[2,12],13:[2,12],16:[2,12],24:[2,12],26:[2,12],28:[2,12],29:[2,12],31:[2,12],32:[2,12],34:[2,12]},{25:[1,80]},{25:[2,45]},{51:[1,78]},{5:[2,20],12:[2,20],13:[2,20],16:[2,20],24:[2,20],26:[2,20],28:[2,20],29:[2,20],31:[2,20],32:[2,20],34:[2,20]},{46:[1,81]},{18:[2,53],25:[2,53],33:[2,53],46:[2,53],50:[2,53]},{30:51,36:82,41:55,42:[1,52],43:[1,53],44:[1,54],45:[1,56],50:[1,26],52:[1,25],53:24},{25:[1,83]},{5:[2,19],12:[2,19],13:[2,19],16:[2,19],24:[2,19],26:[2,19],28:[2,19],29:[2,19],31:[2,19],32:[2,19],34:[2,19]},{18:[2,28],25:[2,28],33:[2,28],42:[2,28],43:[2,28],44:[2,28],45:[2,28],46:[2,28],50:[2,28],52:[2,28]},{18:[2,30],25:[2,30],33:[2,30],46:[2,30],50:[2,30]},{5:[2,16],12:[2,16],13:[2,16],16:[2,16],24:[2,16],26:[2,16],28:[2,16],29:[2,16],31:[2,16],32:[2,16],34:[2,16]}],
|
985
|
+
defaultActions: {4:[2,1],44:[2,41],47:[2,43],57:[2,47],63:[2,10],70:[2,15],73:[2,45]},
|
870
986
|
parseError: function parseError(str, hash) {
|
871
987
|
throw new Error(str);
|
872
988
|
},
|
@@ -974,15 +1090,6 @@ var __module9__ = (function() {
|
|
974
1090
|
return true;
|
975
1091
|
}
|
976
1092
|
};
|
977
|
-
|
978
|
-
|
979
|
-
function stripFlags(open, close) {
|
980
|
-
return {
|
981
|
-
left: open.charAt(2) === '~',
|
982
|
-
right: close.charAt(0) === '~' || close.charAt(1) === '~'
|
983
|
-
};
|
984
|
-
}
|
985
|
-
|
986
1093
|
/* Jison generated lexer */
|
987
1094
|
var lexer = (function(){
|
988
1095
|
var lexer = ({EOF:1,
|
@@ -1172,80 +1279,100 @@ var __module9__ = (function() {
|
|
1172
1279
|
} else {
|
1173
1280
|
this.begin("mu");
|
1174
1281
|
}
|
1175
|
-
if(yy_.yytext) return
|
1282
|
+
if(yy_.yytext) return 12;
|
1176
1283
|
|
1177
1284
|
break;
|
1178
|
-
case 1:return
|
1285
|
+
case 1:return 12;
|
1179
1286
|
break;
|
1180
1287
|
case 2:
|
1181
1288
|
this.popState();
|
1182
|
-
return
|
1289
|
+
return 12;
|
1183
1290
|
|
1184
1291
|
break;
|
1185
|
-
case 3:
|
1292
|
+
case 3:
|
1293
|
+
yy_.yytext = yy_.yytext.substr(5, yy_.yyleng-9);
|
1294
|
+
this.popState();
|
1295
|
+
return 15;
|
1296
|
+
|
1297
|
+
break;
|
1298
|
+
case 4: return 12;
|
1299
|
+
break;
|
1300
|
+
case 5:strip(0,4); this.popState(); return 13;
|
1301
|
+
break;
|
1302
|
+
case 6:return 45;
|
1303
|
+
break;
|
1304
|
+
case 7:return 46;
|
1305
|
+
break;
|
1306
|
+
case 8: return 16;
|
1307
|
+
break;
|
1308
|
+
case 9:
|
1309
|
+
this.popState();
|
1310
|
+
this.begin('raw');
|
1311
|
+
return 18;
|
1312
|
+
|
1186
1313
|
break;
|
1187
|
-
case
|
1314
|
+
case 10:return 34;
|
1188
1315
|
break;
|
1189
|
-
case
|
1316
|
+
case 11:return 24;
|
1190
1317
|
break;
|
1191
|
-
case
|
1318
|
+
case 12:return 29;
|
1192
1319
|
break;
|
1193
|
-
case
|
1320
|
+
case 13:this.popState(); return 28;
|
1194
1321
|
break;
|
1195
|
-
case
|
1322
|
+
case 14:this.popState(); return 28;
|
1196
1323
|
break;
|
1197
|
-
case
|
1324
|
+
case 15:return 26;
|
1198
1325
|
break;
|
1199
|
-
case
|
1326
|
+
case 16:return 26;
|
1200
1327
|
break;
|
1201
|
-
case
|
1328
|
+
case 17:return 32;
|
1202
1329
|
break;
|
1203
|
-
case
|
1330
|
+
case 18:return 31;
|
1204
1331
|
break;
|
1205
|
-
case
|
1332
|
+
case 19:this.popState(); this.begin('com');
|
1206
1333
|
break;
|
1207
|
-
case
|
1334
|
+
case 20:strip(3,5); this.popState(); return 13;
|
1208
1335
|
break;
|
1209
|
-
case
|
1336
|
+
case 21:return 31;
|
1210
1337
|
break;
|
1211
|
-
case
|
1338
|
+
case 22:return 51;
|
1212
1339
|
break;
|
1213
|
-
case
|
1340
|
+
case 23:return 50;
|
1214
1341
|
break;
|
1215
|
-
case
|
1342
|
+
case 24:return 50;
|
1216
1343
|
break;
|
1217
|
-
case
|
1344
|
+
case 25:return 54;
|
1218
1345
|
break;
|
1219
|
-
case
|
1346
|
+
case 26:// ignore whitespace
|
1220
1347
|
break;
|
1221
|
-
case
|
1348
|
+
case 27:this.popState(); return 33;
|
1222
1349
|
break;
|
1223
|
-
case
|
1350
|
+
case 28:this.popState(); return 25;
|
1224
1351
|
break;
|
1225
|
-
case
|
1352
|
+
case 29:yy_.yytext = strip(1,2).replace(/\\"/g,'"'); return 42;
|
1226
1353
|
break;
|
1227
|
-
case
|
1354
|
+
case 30:yy_.yytext = strip(1,2).replace(/\\'/g,"'"); return 42;
|
1228
1355
|
break;
|
1229
|
-
case
|
1356
|
+
case 31:return 52;
|
1230
1357
|
break;
|
1231
|
-
case
|
1358
|
+
case 32:return 44;
|
1232
1359
|
break;
|
1233
|
-
case
|
1360
|
+
case 33:return 44;
|
1234
1361
|
break;
|
1235
|
-
case
|
1362
|
+
case 34:return 43;
|
1236
1363
|
break;
|
1237
|
-
case
|
1364
|
+
case 35:return 50;
|
1238
1365
|
break;
|
1239
|
-
case
|
1366
|
+
case 36:yy_.yytext = strip(1,2); return 50;
|
1240
1367
|
break;
|
1241
|
-
case
|
1368
|
+
case 37:return 'INVALID';
|
1242
1369
|
break;
|
1243
|
-
case
|
1370
|
+
case 38:return 5;
|
1244
1371
|
break;
|
1245
1372
|
}
|
1246
1373
|
};
|
1247
|
-
lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:-?[0-9]+(?=([~}\s)])))/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
|
1248
|
-
lexer.conditions = {"mu":{"rules":[
|
1374
|
+
lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]*?(?=(\{\{\{\{\/)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
|
1375
|
+
lexer.conditions = {"mu":{"rules":[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"com":{"rules":[5],"inclusive":false},"raw":{"rules":[3,4],"inclusive":false},"INITIAL":{"rules":[0,1,38],"inclusive":true}};
|
1249
1376
|
return lexer;})()
|
1250
1377
|
parser.lexer = lexer;
|
1251
1378
|
function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
|
@@ -1255,32 +1382,234 @@ var __module9__ = (function() {
|
|
1255
1382
|
return __exports__;
|
1256
1383
|
})();
|
1257
1384
|
|
1385
|
+
// handlebars/compiler/helpers.js
|
1386
|
+
var __module10__ = (function(__dependency1__) {
|
1387
|
+
"use strict";
|
1388
|
+
var __exports__ = {};
|
1389
|
+
var Exception = __dependency1__;
|
1390
|
+
|
1391
|
+
function stripFlags(open, close) {
|
1392
|
+
return {
|
1393
|
+
left: open.charAt(2) === '~',
|
1394
|
+
right: close.charAt(close.length-3) === '~'
|
1395
|
+
};
|
1396
|
+
}
|
1397
|
+
|
1398
|
+
__exports__.stripFlags = stripFlags;
|
1399
|
+
function prepareBlock(mustache, program, inverseAndProgram, close, inverted, locInfo) {
|
1400
|
+
/*jshint -W040 */
|
1401
|
+
if (mustache.sexpr.id.original !== close.path.original) {
|
1402
|
+
throw new Exception(mustache.sexpr.id.original + ' doesn\'t match ' + close.path.original, mustache);
|
1403
|
+
}
|
1404
|
+
|
1405
|
+
var inverse = inverseAndProgram && inverseAndProgram.program;
|
1406
|
+
|
1407
|
+
var strip = {
|
1408
|
+
left: mustache.strip.left,
|
1409
|
+
right: close.strip.right,
|
1410
|
+
|
1411
|
+
// Determine the standalone candiacy. Basically flag our content as being possibly standalone
|
1412
|
+
// so our parent can determine if we actually are standalone
|
1413
|
+
openStandalone: isNextWhitespace(program.statements),
|
1414
|
+
closeStandalone: isPrevWhitespace((inverse || program).statements)
|
1415
|
+
};
|
1416
|
+
|
1417
|
+
if (mustache.strip.right) {
|
1418
|
+
omitRight(program.statements, null, true);
|
1419
|
+
}
|
1420
|
+
|
1421
|
+
if (inverse) {
|
1422
|
+
var inverseStrip = inverseAndProgram.strip;
|
1423
|
+
|
1424
|
+
if (inverseStrip.left) {
|
1425
|
+
omitLeft(program.statements, null, true);
|
1426
|
+
}
|
1427
|
+
if (inverseStrip.right) {
|
1428
|
+
omitRight(inverse.statements, null, true);
|
1429
|
+
}
|
1430
|
+
if (close.strip.left) {
|
1431
|
+
omitLeft(inverse.statements, null, true);
|
1432
|
+
}
|
1433
|
+
|
1434
|
+
// Find standalone else statments
|
1435
|
+
if (isPrevWhitespace(program.statements)
|
1436
|
+
&& isNextWhitespace(inverse.statements)) {
|
1437
|
+
|
1438
|
+
omitLeft(program.statements);
|
1439
|
+
omitRight(inverse.statements);
|
1440
|
+
}
|
1441
|
+
} else {
|
1442
|
+
if (close.strip.left) {
|
1443
|
+
omitLeft(program.statements, null, true);
|
1444
|
+
}
|
1445
|
+
}
|
1446
|
+
|
1447
|
+
if (inverted) {
|
1448
|
+
return new this.BlockNode(mustache, inverse, program, strip, locInfo);
|
1449
|
+
} else {
|
1450
|
+
return new this.BlockNode(mustache, program, inverse, strip, locInfo);
|
1451
|
+
}
|
1452
|
+
}
|
1453
|
+
|
1454
|
+
__exports__.prepareBlock = prepareBlock;
|
1455
|
+
function prepareProgram(statements, isRoot) {
|
1456
|
+
for (var i = 0, l = statements.length; i < l; i++) {
|
1457
|
+
var current = statements[i],
|
1458
|
+
strip = current.strip;
|
1459
|
+
|
1460
|
+
if (!strip) {
|
1461
|
+
continue;
|
1462
|
+
}
|
1463
|
+
|
1464
|
+
var _isPrevWhitespace = isPrevWhitespace(statements, i, isRoot, current.type === 'partial'),
|
1465
|
+
_isNextWhitespace = isNextWhitespace(statements, i, isRoot),
|
1466
|
+
|
1467
|
+
openStandalone = strip.openStandalone && _isPrevWhitespace,
|
1468
|
+
closeStandalone = strip.closeStandalone && _isNextWhitespace,
|
1469
|
+
inlineStandalone = strip.inlineStandalone && _isPrevWhitespace && _isNextWhitespace;
|
1470
|
+
|
1471
|
+
if (strip.right) {
|
1472
|
+
omitRight(statements, i, true);
|
1473
|
+
}
|
1474
|
+
if (strip.left) {
|
1475
|
+
omitLeft(statements, i, true);
|
1476
|
+
}
|
1477
|
+
|
1478
|
+
if (inlineStandalone) {
|
1479
|
+
omitRight(statements, i);
|
1480
|
+
|
1481
|
+
if (omitLeft(statements, i)) {
|
1482
|
+
// If we are on a standalone node, save the indent info for partials
|
1483
|
+
if (current.type === 'partial') {
|
1484
|
+
current.indent = (/([ \t]+$)/).exec(statements[i-1].original) ? RegExp.$1 : '';
|
1485
|
+
}
|
1486
|
+
}
|
1487
|
+
}
|
1488
|
+
if (openStandalone) {
|
1489
|
+
omitRight((current.program || current.inverse).statements);
|
1490
|
+
|
1491
|
+
// Strip out the previous content node if it's whitespace only
|
1492
|
+
omitLeft(statements, i);
|
1493
|
+
}
|
1494
|
+
if (closeStandalone) {
|
1495
|
+
// Always strip the next node
|
1496
|
+
omitRight(statements, i);
|
1497
|
+
|
1498
|
+
omitLeft((current.inverse || current.program).statements);
|
1499
|
+
}
|
1500
|
+
}
|
1501
|
+
|
1502
|
+
return statements;
|
1503
|
+
}
|
1504
|
+
|
1505
|
+
__exports__.prepareProgram = prepareProgram;function isPrevWhitespace(statements, i, isRoot) {
|
1506
|
+
if (i === undefined) {
|
1507
|
+
i = statements.length;
|
1508
|
+
}
|
1509
|
+
|
1510
|
+
// Nodes that end with newlines are considered whitespace (but are special
|
1511
|
+
// cased for strip operations)
|
1512
|
+
var prev = statements[i-1],
|
1513
|
+
sibling = statements[i-2];
|
1514
|
+
if (!prev) {
|
1515
|
+
return isRoot;
|
1516
|
+
}
|
1517
|
+
|
1518
|
+
if (prev.type === 'content') {
|
1519
|
+
return (sibling || !isRoot ? (/\r?\n\s*?$/) : (/(^|\r?\n)\s*?$/)).test(prev.original);
|
1520
|
+
}
|
1521
|
+
}
|
1522
|
+
function isNextWhitespace(statements, i, isRoot) {
|
1523
|
+
if (i === undefined) {
|
1524
|
+
i = -1;
|
1525
|
+
}
|
1526
|
+
|
1527
|
+
var next = statements[i+1],
|
1528
|
+
sibling = statements[i+2];
|
1529
|
+
if (!next) {
|
1530
|
+
return isRoot;
|
1531
|
+
}
|
1532
|
+
|
1533
|
+
if (next.type === 'content') {
|
1534
|
+
return (sibling || !isRoot ? (/^\s*?\r?\n/) : (/^\s*?(\r?\n|$)/)).test(next.original);
|
1535
|
+
}
|
1536
|
+
}
|
1537
|
+
|
1538
|
+
// Marks the node to the right of the position as omitted.
|
1539
|
+
// I.e. {{foo}}' ' will mark the ' ' node as omitted.
|
1540
|
+
//
|
1541
|
+
// If i is undefined, then the first child will be marked as such.
|
1542
|
+
//
|
1543
|
+
// If mulitple is truthy then all whitespace will be stripped out until non-whitespace
|
1544
|
+
// content is met.
|
1545
|
+
function omitRight(statements, i, multiple) {
|
1546
|
+
var current = statements[i == null ? 0 : i + 1];
|
1547
|
+
if (!current || current.type !== 'content' || (!multiple && current.rightStripped)) {
|
1548
|
+
return;
|
1549
|
+
}
|
1550
|
+
|
1551
|
+
var original = current.string;
|
1552
|
+
current.string = current.string.replace(multiple ? (/^\s+/) : (/^[ \t]*\r?\n?/), '');
|
1553
|
+
current.rightStripped = current.string !== original;
|
1554
|
+
}
|
1555
|
+
|
1556
|
+
// Marks the node to the left of the position as omitted.
|
1557
|
+
// I.e. ' '{{foo}} will mark the ' ' node as omitted.
|
1558
|
+
//
|
1559
|
+
// If i is undefined then the last child will be marked as such.
|
1560
|
+
//
|
1561
|
+
// If mulitple is truthy then all whitespace will be stripped out until non-whitespace
|
1562
|
+
// content is met.
|
1563
|
+
function omitLeft(statements, i, multiple) {
|
1564
|
+
var current = statements[i == null ? statements.length - 1 : i - 1];
|
1565
|
+
if (!current || current.type !== 'content' || (!multiple && current.leftStripped)) {
|
1566
|
+
return;
|
1567
|
+
}
|
1568
|
+
|
1569
|
+
// We omit the last node if it's whitespace only and not preceeded by a non-content node.
|
1570
|
+
var original = current.string;
|
1571
|
+
current.string = current.string.replace(multiple ? (/\s+$/) : (/[ \t]+$/), '');
|
1572
|
+
current.leftStripped = current.string !== original;
|
1573
|
+
return current.leftStripped;
|
1574
|
+
}
|
1575
|
+
return __exports__;
|
1576
|
+
})(__module5__);
|
1577
|
+
|
1258
1578
|
// handlebars/compiler/base.js
|
1259
|
-
var __module8__ = (function(__dependency1__, __dependency2__) {
|
1579
|
+
var __module8__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {
|
1260
1580
|
"use strict";
|
1261
1581
|
var __exports__ = {};
|
1262
1582
|
var parser = __dependency1__;
|
1263
1583
|
var AST = __dependency2__;
|
1584
|
+
var Helpers = __dependency3__;
|
1585
|
+
var extend = __dependency4__.extend;
|
1264
1586
|
|
1265
1587
|
__exports__.parser = parser;
|
1266
1588
|
|
1589
|
+
var yy = {};
|
1590
|
+
extend(yy, Helpers, AST);
|
1591
|
+
|
1267
1592
|
function parse(input) {
|
1268
1593
|
// Just return if an already-compile AST was passed in.
|
1269
|
-
if(input.constructor === AST.ProgramNode) { return input; }
|
1594
|
+
if (input.constructor === AST.ProgramNode) { return input; }
|
1595
|
+
|
1596
|
+
parser.yy = yy;
|
1270
1597
|
|
1271
|
-
parser.yy = AST;
|
1272
1598
|
return parser.parse(input);
|
1273
1599
|
}
|
1274
1600
|
|
1275
1601
|
__exports__.parse = parse;
|
1276
1602
|
return __exports__;
|
1277
|
-
})(__module9__, __module7__);
|
1603
|
+
})(__module9__, __module7__, __module10__, __module3__);
|
1278
1604
|
|
1279
1605
|
// handlebars/compiler/compiler.js
|
1280
|
-
var
|
1606
|
+
var __module11__ = (function(__dependency1__, __dependency2__) {
|
1281
1607
|
"use strict";
|
1282
1608
|
var __exports__ = {};
|
1283
1609
|
var Exception = __dependency1__;
|
1610
|
+
var isArray = __dependency2__.isArray;
|
1611
|
+
|
1612
|
+
var slice = [].slice;
|
1284
1613
|
|
1285
1614
|
function Compiler() {}
|
1286
1615
|
|
@@ -1292,30 +1621,6 @@ var __module10__ = (function(__dependency1__) {
|
|
1292
1621
|
Compiler.prototype = {
|
1293
1622
|
compiler: Compiler,
|
1294
1623
|
|
1295
|
-
disassemble: function() {
|
1296
|
-
var opcodes = this.opcodes, opcode, out = [], params, param;
|
1297
|
-
|
1298
|
-
for (var i=0, l=opcodes.length; i<l; i++) {
|
1299
|
-
opcode = opcodes[i];
|
1300
|
-
|
1301
|
-
if (opcode.opcode === 'DECLARE') {
|
1302
|
-
out.push("DECLARE " + opcode.name + "=" + opcode.value);
|
1303
|
-
} else {
|
1304
|
-
params = [];
|
1305
|
-
for (var j=0; j<opcode.args.length; j++) {
|
1306
|
-
param = opcode.args[j];
|
1307
|
-
if (typeof param === "string") {
|
1308
|
-
param = "\"" + param.replace("\n", "\\n") + "\"";
|
1309
|
-
}
|
1310
|
-
params.push(param);
|
1311
|
-
}
|
1312
|
-
out.push(opcode.opcode + " " + params.join(" "));
|
1313
|
-
}
|
1314
|
-
}
|
1315
|
-
|
1316
|
-
return out.join("\n");
|
1317
|
-
},
|
1318
|
-
|
1319
1624
|
equals: function(other) {
|
1320
1625
|
var len = this.opcodes.length;
|
1321
1626
|
if (other.opcodes.length !== len) {
|
@@ -1325,20 +1630,14 @@ var __module10__ = (function(__dependency1__) {
|
|
1325
1630
|
for (var i = 0; i < len; i++) {
|
1326
1631
|
var opcode = this.opcodes[i],
|
1327
1632
|
otherOpcode = other.opcodes[i];
|
1328
|
-
if (opcode.opcode !== otherOpcode.opcode || opcode.args
|
1633
|
+
if (opcode.opcode !== otherOpcode.opcode || !argEquals(opcode.args, otherOpcode.args)) {
|
1329
1634
|
return false;
|
1330
1635
|
}
|
1331
|
-
for (var j = 0; j < opcode.args.length; j++) {
|
1332
|
-
if (opcode.args[j] !== otherOpcode.args[j]) {
|
1333
|
-
return false;
|
1334
|
-
}
|
1335
|
-
}
|
1336
1636
|
}
|
1337
1637
|
|
1638
|
+
// We know that length is the same between the two arrays because they are directly tied
|
1639
|
+
// to the opcode behavior above.
|
1338
1640
|
len = this.children.length;
|
1339
|
-
if (other.children.length !== len) {
|
1340
|
-
return false;
|
1341
|
-
}
|
1342
1641
|
for (i = 0; i < len; i++) {
|
1343
1642
|
if (!this.children[i].equals(other.children[i])) {
|
1344
1643
|
return false;
|
@@ -1355,6 +1654,8 @@ var __module10__ = (function(__dependency1__) {
|
|
1355
1654
|
this.children = [];
|
1356
1655
|
this.depths = {list: []};
|
1357
1656
|
this.options = options;
|
1657
|
+
this.stringParams = options.stringParams;
|
1658
|
+
this.trackIds = options.trackIds;
|
1358
1659
|
|
1359
1660
|
// These changes will propagate to the other compiler components
|
1360
1661
|
var knownHelpers = this.options.knownHelpers;
|
@@ -1365,7 +1666,8 @@ var __module10__ = (function(__dependency1__) {
|
|
1365
1666
|
'if': true,
|
1366
1667
|
'unless': true,
|
1367
1668
|
'with': true,
|
1368
|
-
'log': true
|
1669
|
+
'log': true,
|
1670
|
+
'lookup': true
|
1369
1671
|
};
|
1370
1672
|
if (knownHelpers) {
|
1371
1673
|
for (var name in knownHelpers) {
|
@@ -1377,19 +1679,7 @@ var __module10__ = (function(__dependency1__) {
|
|
1377
1679
|
},
|
1378
1680
|
|
1379
1681
|
accept: function(node) {
|
1380
|
-
|
1381
|
-
ret;
|
1382
|
-
if (strip.left) {
|
1383
|
-
this.opcode('strip');
|
1384
|
-
}
|
1385
|
-
|
1386
|
-
ret = this[node.type](node);
|
1387
|
-
|
1388
|
-
if (strip.right) {
|
1389
|
-
this.opcode('strip');
|
1390
|
-
}
|
1391
|
-
|
1392
|
-
return ret;
|
1682
|
+
return this[node.type](node);
|
1393
1683
|
},
|
1394
1684
|
|
1395
1685
|
program: function(program) {
|
@@ -1451,7 +1741,7 @@ var __module10__ = (function(__dependency1__) {
|
|
1451
1741
|
this.opcode('pushProgram', program);
|
1452
1742
|
this.opcode('pushProgram', inverse);
|
1453
1743
|
this.opcode('emptyHash');
|
1454
|
-
this.opcode('blockValue');
|
1744
|
+
this.opcode('blockValue', sexpr.id.original);
|
1455
1745
|
} else {
|
1456
1746
|
this.ambiguousSexpr(sexpr, program, inverse);
|
1457
1747
|
|
@@ -1467,31 +1757,15 @@ var __module10__ = (function(__dependency1__) {
|
|
1467
1757
|
},
|
1468
1758
|
|
1469
1759
|
hash: function(hash) {
|
1470
|
-
var pairs = hash.pairs,
|
1760
|
+
var pairs = hash.pairs, i, l;
|
1471
1761
|
|
1472
1762
|
this.opcode('pushHash');
|
1473
1763
|
|
1474
|
-
for(
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
if(val.depth) {
|
1480
|
-
this.addDepth(val.depth);
|
1481
|
-
}
|
1482
|
-
this.opcode('getContext', val.depth || 0);
|
1483
|
-
this.opcode('pushStringParam', val.stringModeValue, val.type);
|
1484
|
-
|
1485
|
-
if (val.type === 'sexpr') {
|
1486
|
-
// Subexpressions get evaluated and passed in
|
1487
|
-
// in string params mode.
|
1488
|
-
this.sexpr(val);
|
1489
|
-
}
|
1490
|
-
} else {
|
1491
|
-
this.accept(val);
|
1492
|
-
}
|
1493
|
-
|
1494
|
-
this.opcode('assignToHash', pair[0]);
|
1764
|
+
for(i=0, l=pairs.length; i<l; i++) {
|
1765
|
+
this.pushParam(pairs[i][1]);
|
1766
|
+
}
|
1767
|
+
while(i--) {
|
1768
|
+
this.opcode('assignToHash', pairs[i][0]);
|
1495
1769
|
}
|
1496
1770
|
this.opcode('popHash');
|
1497
1771
|
},
|
@@ -1500,18 +1774,27 @@ var __module10__ = (function(__dependency1__) {
|
|
1500
1774
|
var partialName = partial.partialName;
|
1501
1775
|
this.usePartial = true;
|
1502
1776
|
|
1503
|
-
if(partial.
|
1504
|
-
this.
|
1777
|
+
if (partial.hash) {
|
1778
|
+
this.accept(partial.hash);
|
1505
1779
|
} else {
|
1506
|
-
this.opcode('push', '
|
1780
|
+
this.opcode('push', 'undefined');
|
1507
1781
|
}
|
1508
1782
|
|
1509
|
-
|
1783
|
+
if (partial.context) {
|
1784
|
+
this.accept(partial.context);
|
1785
|
+
} else {
|
1786
|
+
this.opcode('getContext', 0);
|
1787
|
+
this.opcode('pushContext');
|
1788
|
+
}
|
1789
|
+
|
1790
|
+
this.opcode('invokePartial', partialName.name, partial.indent || '');
|
1510
1791
|
this.opcode('append');
|
1511
1792
|
},
|
1512
1793
|
|
1513
1794
|
content: function(content) {
|
1514
|
-
|
1795
|
+
if (content.string) {
|
1796
|
+
this.opcode('appendContent', content.string);
|
1797
|
+
}
|
1515
1798
|
},
|
1516
1799
|
|
1517
1800
|
mustache: function(mustache) {
|
@@ -1534,6 +1817,8 @@ var __module10__ = (function(__dependency1__) {
|
|
1534
1817
|
this.opcode('pushProgram', program);
|
1535
1818
|
this.opcode('pushProgram', inverse);
|
1536
1819
|
|
1820
|
+
this.ID(id);
|
1821
|
+
|
1537
1822
|
this.opcode('invokeAmbiguous', name, isBlock);
|
1538
1823
|
},
|
1539
1824
|
|
@@ -1556,14 +1841,18 @@ var __module10__ = (function(__dependency1__) {
|
|
1556
1841
|
|
1557
1842
|
helperSexpr: function(sexpr, program, inverse) {
|
1558
1843
|
var params = this.setupFullMustacheParams(sexpr, program, inverse),
|
1559
|
-
|
1844
|
+
id = sexpr.id,
|
1845
|
+
name = id.parts[0];
|
1560
1846
|
|
1561
1847
|
if (this.options.knownHelpers[name]) {
|
1562
1848
|
this.opcode('invokeKnownHelper', params.length, name);
|
1563
1849
|
} else if (this.options.knownHelpersOnly) {
|
1564
1850
|
throw new Exception("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr);
|
1565
1851
|
} else {
|
1566
|
-
|
1852
|
+
id.falsy = true;
|
1853
|
+
|
1854
|
+
this.ID(id);
|
1855
|
+
this.opcode('invokeHelper', params.length, id.original, id.isSimple);
|
1567
1856
|
}
|
1568
1857
|
},
|
1569
1858
|
|
@@ -1585,35 +1874,24 @@ var __module10__ = (function(__dependency1__) {
|
|
1585
1874
|
|
1586
1875
|
var name = id.parts[0];
|
1587
1876
|
if (!name) {
|
1877
|
+
// Context reference, i.e. `{{foo .}}` or `{{foo ..}}`
|
1588
1878
|
this.opcode('pushContext');
|
1589
1879
|
} else {
|
1590
|
-
this.opcode('lookupOnContext', id.parts
|
1591
|
-
}
|
1592
|
-
|
1593
|
-
for(var i=1, l=id.parts.length; i<l; i++) {
|
1594
|
-
this.opcode('lookup', id.parts[i]);
|
1880
|
+
this.opcode('lookupOnContext', id.parts, id.falsy, id.isScoped);
|
1595
1881
|
}
|
1596
1882
|
},
|
1597
1883
|
|
1598
1884
|
DATA: function(data) {
|
1599
1885
|
this.options.data = true;
|
1600
|
-
|
1601
|
-
throw new Exception('Scoped data references are not supported: ' + data.original, data);
|
1602
|
-
}
|
1603
|
-
|
1604
|
-
this.opcode('lookupData');
|
1605
|
-
var parts = data.id.parts;
|
1606
|
-
for(var i=0, l=parts.length; i<l; i++) {
|
1607
|
-
this.opcode('lookup', parts[i]);
|
1608
|
-
}
|
1886
|
+
this.opcode('lookupData', data.id.depth, data.id.parts);
|
1609
1887
|
},
|
1610
1888
|
|
1611
1889
|
STRING: function(string) {
|
1612
1890
|
this.opcode('pushString', string.string);
|
1613
1891
|
},
|
1614
1892
|
|
1615
|
-
|
1616
|
-
this.opcode('pushLiteral',
|
1893
|
+
NUMBER: function(number) {
|
1894
|
+
this.opcode('pushLiteral', number.number);
|
1617
1895
|
},
|
1618
1896
|
|
1619
1897
|
BOOLEAN: function(bool) {
|
@@ -1624,11 +1902,7 @@ var __module10__ = (function(__dependency1__) {
|
|
1624
1902
|
|
1625
1903
|
// HELPERS
|
1626
1904
|
opcode: function(name) {
|
1627
|
-
this.opcodes.push({ opcode: name, args:
|
1628
|
-
},
|
1629
|
-
|
1630
|
-
declare: function(name, value) {
|
1631
|
-
this.opcodes.push({ opcode: 'DECLARE', name: name, value: value });
|
1905
|
+
this.opcodes.push({ opcode: name, args: slice.call(arguments, 1) });
|
1632
1906
|
},
|
1633
1907
|
|
1634
1908
|
addDepth: function(depth) {
|
@@ -1646,6 +1920,7 @@ var __module10__ = (function(__dependency1__) {
|
|
1646
1920
|
var options = this.options;
|
1647
1921
|
|
1648
1922
|
// if ambiguous, we can possibly resolve the ambiguity now
|
1923
|
+
// An eligible helper is one that does not have a complex path, i.e. `this.foo`, `../foo` etc.
|
1649
1924
|
if (isEligible && !isHelper) {
|
1650
1925
|
var name = sexpr.id.parts[0];
|
1651
1926
|
|
@@ -1662,27 +1937,29 @@ var __module10__ = (function(__dependency1__) {
|
|
1662
1937
|
},
|
1663
1938
|
|
1664
1939
|
pushParams: function(params) {
|
1665
|
-
var i =
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
if(this.options.stringParams) {
|
1671
|
-
if(param.depth) {
|
1672
|
-
this.addDepth(param.depth);
|
1673
|
-
}
|
1940
|
+
for(var i=0, l=params.length; i<l; i++) {
|
1941
|
+
this.pushParam(params[i]);
|
1942
|
+
}
|
1943
|
+
},
|
1674
1944
|
|
1675
|
-
|
1676
|
-
|
1945
|
+
pushParam: function(val) {
|
1946
|
+
if (this.stringParams) {
|
1947
|
+
if(val.depth) {
|
1948
|
+
this.addDepth(val.depth);
|
1949
|
+
}
|
1950
|
+
this.opcode('getContext', val.depth || 0);
|
1951
|
+
this.opcode('pushStringParam', val.stringModeValue, val.type);
|
1677
1952
|
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1953
|
+
if (val.type === 'sexpr') {
|
1954
|
+
// Subexpressions get evaluated and passed in
|
1955
|
+
// in string params mode.
|
1956
|
+
this.sexpr(val);
|
1957
|
+
}
|
1958
|
+
} else {
|
1959
|
+
if (this.trackIds) {
|
1960
|
+
this.opcode('pushId', val.type, val.idName || val.stringModeValue);
|
1685
1961
|
}
|
1962
|
+
this.accept(val);
|
1686
1963
|
}
|
1687
1964
|
},
|
1688
1965
|
|
@@ -1712,6 +1989,9 @@ var __module10__ = (function(__dependency1__) {
|
|
1712
1989
|
if (!('data' in options)) {
|
1713
1990
|
options.data = true;
|
1714
1991
|
}
|
1992
|
+
if (options.compat) {
|
1993
|
+
options.useDepths = true;
|
1994
|
+
}
|
1715
1995
|
|
1716
1996
|
var ast = env.parse(input);
|
1717
1997
|
var environment = new env.Compiler().compile(ast, options);
|
@@ -1728,6 +2008,9 @@ var __module10__ = (function(__dependency1__) {
|
|
1728
2008
|
if (!('data' in options)) {
|
1729
2009
|
options.data = true;
|
1730
2010
|
}
|
2011
|
+
if (options.compat) {
|
2012
|
+
options.useDepths = true;
|
2013
|
+
}
|
1731
2014
|
|
1732
2015
|
var compiled;
|
1733
2016
|
|
@@ -1739,25 +2022,50 @@ var __module10__ = (function(__dependency1__) {
|
|
1739
2022
|
}
|
1740
2023
|
|
1741
2024
|
// Template is only compiled on first use and cached after that point.
|
1742
|
-
|
2025
|
+
var ret = function(context, options) {
|
1743
2026
|
if (!compiled) {
|
1744
2027
|
compiled = compileInput();
|
1745
2028
|
}
|
1746
2029
|
return compiled.call(this, context, options);
|
1747
2030
|
};
|
2031
|
+
ret._setup = function(options) {
|
2032
|
+
if (!compiled) {
|
2033
|
+
compiled = compileInput();
|
2034
|
+
}
|
2035
|
+
return compiled._setup(options);
|
2036
|
+
};
|
2037
|
+
ret._child = function(i, data, depths) {
|
2038
|
+
if (!compiled) {
|
2039
|
+
compiled = compileInput();
|
2040
|
+
}
|
2041
|
+
return compiled._child(i, data, depths);
|
2042
|
+
};
|
2043
|
+
return ret;
|
1748
2044
|
}
|
1749
2045
|
|
1750
|
-
__exports__.compile = compile;
|
2046
|
+
__exports__.compile = compile;function argEquals(a, b) {
|
2047
|
+
if (a === b) {
|
2048
|
+
return true;
|
2049
|
+
}
|
2050
|
+
|
2051
|
+
if (isArray(a) && isArray(b) && a.length === b.length) {
|
2052
|
+
for (var i = 0; i < a.length; i++) {
|
2053
|
+
if (!argEquals(a[i], b[i])) {
|
2054
|
+
return false;
|
2055
|
+
}
|
2056
|
+
}
|
2057
|
+
return true;
|
2058
|
+
}
|
2059
|
+
}
|
1751
2060
|
return __exports__;
|
1752
|
-
})(__module5__);
|
2061
|
+
})(__module5__, __module3__);
|
1753
2062
|
|
1754
2063
|
// handlebars/compiler/javascript-compiler.js
|
1755
|
-
var
|
2064
|
+
var __module12__ = (function(__dependency1__, __dependency2__) {
|
1756
2065
|
"use strict";
|
1757
2066
|
var __exports__;
|
1758
2067
|
var COMPILER_REVISION = __dependency1__.COMPILER_REVISION;
|
1759
2068
|
var REVISION_CHANGES = __dependency1__.REVISION_CHANGES;
|
1760
|
-
var log = __dependency1__.log;
|
1761
2069
|
var Exception = __dependency2__;
|
1762
2070
|
|
1763
2071
|
function Literal(value) {
|
@@ -1770,32 +2078,22 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
1770
2078
|
// PUBLIC API: You can override these methods in a subclass to provide
|
1771
2079
|
// alternative compiled forms for name lookup and buffering semantics
|
1772
2080
|
nameLookup: function(parent, name /* , type*/) {
|
1773
|
-
|
1774
|
-
|
1775
|
-
if (parent.indexOf('depth') === 0) {
|
1776
|
-
wrap = true;
|
1777
|
-
}
|
1778
|
-
|
1779
|
-
if (/^[0-9]+$/.test(name)) {
|
1780
|
-
ret = parent + "[" + name + "]";
|
1781
|
-
} else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
|
1782
|
-
ret = parent + "." + name;
|
1783
|
-
}
|
1784
|
-
else {
|
1785
|
-
ret = parent + "['" + name + "']";
|
1786
|
-
}
|
1787
|
-
|
1788
|
-
if (wrap) {
|
1789
|
-
return '(' + parent + ' && ' + ret + ')';
|
2081
|
+
if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
|
2082
|
+
return parent + "." + name;
|
1790
2083
|
} else {
|
1791
|
-
return
|
2084
|
+
return parent + "['" + name + "']";
|
1792
2085
|
}
|
1793
2086
|
},
|
2087
|
+
depthedLookup: function(name) {
|
2088
|
+
this.aliases.lookup = 'this.lookup';
|
2089
|
+
|
2090
|
+
return 'lookup(depths, "' + name + '")';
|
2091
|
+
},
|
1794
2092
|
|
1795
2093
|
compilerInfo: function() {
|
1796
2094
|
var revision = COMPILER_REVISION,
|
1797
2095
|
versions = REVISION_CHANGES[revision];
|
1798
|
-
return
|
2096
|
+
return [revision, versions];
|
1799
2097
|
},
|
1800
2098
|
|
1801
2099
|
appendToBuffer: function(string) {
|
@@ -1819,22 +2117,23 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
1819
2117
|
|
1820
2118
|
compile: function(environment, options, context, asObject) {
|
1821
2119
|
this.environment = environment;
|
1822
|
-
this.options = options
|
1823
|
-
|
1824
|
-
|
2120
|
+
this.options = options;
|
2121
|
+
this.stringParams = this.options.stringParams;
|
2122
|
+
this.trackIds = this.options.trackIds;
|
2123
|
+
this.precompile = !asObject;
|
1825
2124
|
|
1826
2125
|
this.name = this.environment.name;
|
1827
2126
|
this.isChild = !!context;
|
1828
2127
|
this.context = context || {
|
1829
2128
|
programs: [],
|
1830
|
-
environments: []
|
1831
|
-
aliases: { }
|
2129
|
+
environments: []
|
1832
2130
|
};
|
1833
2131
|
|
1834
2132
|
this.preamble();
|
1835
2133
|
|
1836
2134
|
this.stackSlot = 0;
|
1837
2135
|
this.stackVars = [];
|
2136
|
+
this.aliases = {};
|
1838
2137
|
this.registers = { list: [] };
|
1839
2138
|
this.hashes = [];
|
1840
2139
|
this.compileStack = [];
|
@@ -1842,118 +2141,109 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
1842
2141
|
|
1843
2142
|
this.compileChildren(environment, options);
|
1844
2143
|
|
1845
|
-
|
2144
|
+
this.useDepths = this.useDepths || environment.depths.list.length || this.options.compat;
|
1846
2145
|
|
1847
|
-
|
2146
|
+
var opcodes = environment.opcodes,
|
2147
|
+
opcode,
|
2148
|
+
i,
|
2149
|
+
l;
|
1848
2150
|
|
1849
|
-
for(
|
1850
|
-
opcode = opcodes[
|
1851
|
-
|
1852
|
-
if(opcode.opcode === 'DECLARE') {
|
1853
|
-
this[opcode.name] = opcode.value;
|
1854
|
-
} else {
|
1855
|
-
this[opcode.opcode].apply(this, opcode.args);
|
1856
|
-
}
|
2151
|
+
for (i = 0, l = opcodes.length; i < l; i++) {
|
2152
|
+
opcode = opcodes[i];
|
1857
2153
|
|
1858
|
-
|
1859
|
-
if (opcode.opcode !== this.stripNext) {
|
1860
|
-
this.stripNext = false;
|
1861
|
-
}
|
2154
|
+
this[opcode.opcode].apply(this, opcode.args);
|
1862
2155
|
}
|
1863
2156
|
|
1864
2157
|
// Flush any trailing content that might be pending.
|
1865
2158
|
this.pushSource('');
|
1866
2159
|
|
2160
|
+
/* istanbul ignore next */
|
1867
2161
|
if (this.stackSlot || this.inlineStack.length || this.compileStack.length) {
|
1868
2162
|
throw new Exception('Compile completed with content left on stack');
|
1869
2163
|
}
|
1870
2164
|
|
1871
|
-
|
1872
|
-
},
|
1873
|
-
|
1874
|
-
preamble: function() {
|
1875
|
-
var out = [];
|
1876
|
-
|
2165
|
+
var fn = this.createFunctionContext(asObject);
|
1877
2166
|
if (!this.isChild) {
|
1878
|
-
var
|
2167
|
+
var ret = {
|
2168
|
+
compiler: this.compilerInfo(),
|
2169
|
+
main: fn
|
2170
|
+
};
|
2171
|
+
var programs = this.context.programs;
|
2172
|
+
for (i = 0, l = programs.length; i < l; i++) {
|
2173
|
+
if (programs[i]) {
|
2174
|
+
ret[i] = programs[i];
|
2175
|
+
}
|
2176
|
+
}
|
1879
2177
|
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
2178
|
+
if (this.environment.usePartial) {
|
2179
|
+
ret.usePartial = true;
|
2180
|
+
}
|
2181
|
+
if (this.options.data) {
|
2182
|
+
ret.useData = true;
|
2183
|
+
}
|
2184
|
+
if (this.useDepths) {
|
2185
|
+
ret.useDepths = true;
|
2186
|
+
}
|
2187
|
+
if (this.options.compat) {
|
2188
|
+
ret.compat = true;
|
2189
|
+
}
|
2190
|
+
|
2191
|
+
if (!asObject) {
|
2192
|
+
ret.compiler = JSON.stringify(ret.compiler);
|
2193
|
+
ret = this.objectLiteral(ret);
|
2194
|
+
}
|
1887
2195
|
|
1888
|
-
|
1889
|
-
out.push(", buffer = " + this.initializeBuffer());
|
2196
|
+
return ret;
|
1890
2197
|
} else {
|
1891
|
-
|
2198
|
+
return fn;
|
1892
2199
|
}
|
2200
|
+
},
|
1893
2201
|
|
2202
|
+
preamble: function() {
|
1894
2203
|
// track the last context pushed into place to allow skipping the
|
1895
2204
|
// getContext opcode when it would be a noop
|
1896
2205
|
this.lastContext = 0;
|
1897
|
-
this.source =
|
2206
|
+
this.source = [];
|
1898
2207
|
},
|
1899
2208
|
|
1900
2209
|
createFunctionContext: function(asObject) {
|
1901
|
-
var
|
2210
|
+
var varDeclarations = '';
|
1902
2211
|
|
2212
|
+
var locals = this.stackVars.concat(this.registers.list);
|
1903
2213
|
if(locals.length > 0) {
|
1904
|
-
|
2214
|
+
varDeclarations += ", " + locals.join(", ");
|
1905
2215
|
}
|
1906
2216
|
|
1907
2217
|
// Generate minimizer alias mappings
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias];
|
1912
|
-
}
|
2218
|
+
for (var alias in this.aliases) {
|
2219
|
+
if (this.aliases.hasOwnProperty(alias)) {
|
2220
|
+
varDeclarations += ', ' + alias + '=' + this.aliases[alias];
|
1913
2221
|
}
|
1914
2222
|
}
|
1915
2223
|
|
1916
|
-
|
1917
|
-
this.source[1] = "var " + this.source[1].substring(2) + ";";
|
1918
|
-
}
|
1919
|
-
|
1920
|
-
// Merge children
|
1921
|
-
if (!this.isChild) {
|
1922
|
-
this.source[1] += '\n' + this.context.programs.join('\n') + '\n';
|
1923
|
-
}
|
2224
|
+
var params = ["depth0", "helpers", "partials", "data"];
|
1924
2225
|
|
1925
|
-
if (
|
1926
|
-
|
1927
|
-
}
|
1928
|
-
|
1929
|
-
var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"];
|
1930
|
-
|
1931
|
-
for(var i=0, l=this.environment.depths.list.length; i<l; i++) {
|
1932
|
-
params.push("depth" + this.environment.depths.list[i]);
|
2226
|
+
if (this.useDepths) {
|
2227
|
+
params.push('depths');
|
1933
2228
|
}
|
1934
2229
|
|
1935
2230
|
// Perform a second pass over the output to merge content when possible
|
1936
|
-
var source = this.mergeSource();
|
1937
|
-
|
1938
|
-
if (!this.isChild) {
|
1939
|
-
source = this.compilerInfo()+source;
|
1940
|
-
}
|
2231
|
+
var source = this.mergeSource(varDeclarations);
|
1941
2232
|
|
1942
2233
|
if (asObject) {
|
1943
2234
|
params.push(source);
|
1944
2235
|
|
1945
2236
|
return Function.apply(this, params);
|
1946
2237
|
} else {
|
1947
|
-
|
1948
|
-
log('debug', functionSource + "\n\n");
|
1949
|
-
return functionSource;
|
2238
|
+
return 'function(' + params.join(',') + ') {\n ' + source + '}';
|
1950
2239
|
}
|
1951
2240
|
},
|
1952
|
-
mergeSource: function() {
|
1953
|
-
// WARN: We are not handling the case where buffer is still populated as the source should
|
1954
|
-
// not have buffer append operations as their final action.
|
2241
|
+
mergeSource: function(varDeclarations) {
|
1955
2242
|
var source = '',
|
1956
|
-
buffer
|
2243
|
+
buffer,
|
2244
|
+
appendOnly = !this.forceBuffer,
|
2245
|
+
appendFirst;
|
2246
|
+
|
1957
2247
|
for (var i = 0, len = this.source.length; i < len; i++) {
|
1958
2248
|
var line = this.source[i];
|
1959
2249
|
if (line.appendToBuffer) {
|
@@ -1964,12 +2254,39 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
1964
2254
|
}
|
1965
2255
|
} else {
|
1966
2256
|
if (buffer) {
|
1967
|
-
source
|
2257
|
+
if (!source) {
|
2258
|
+
appendFirst = true;
|
2259
|
+
source = buffer + ';\n ';
|
2260
|
+
} else {
|
2261
|
+
source += 'buffer += ' + buffer + ';\n ';
|
2262
|
+
}
|
1968
2263
|
buffer = undefined;
|
1969
2264
|
}
|
1970
2265
|
source += line + '\n ';
|
2266
|
+
|
2267
|
+
if (!this.environment.isSimple) {
|
2268
|
+
appendOnly = false;
|
2269
|
+
}
|
2270
|
+
}
|
2271
|
+
}
|
2272
|
+
|
2273
|
+
if (appendOnly) {
|
2274
|
+
if (buffer || !source) {
|
2275
|
+
source += 'return ' + (buffer || '""') + ';\n';
|
2276
|
+
}
|
2277
|
+
} else {
|
2278
|
+
varDeclarations += ", buffer = " + (appendFirst ? '' : this.initializeBuffer());
|
2279
|
+
if (buffer) {
|
2280
|
+
source += 'return buffer + ' + buffer + ';\n';
|
2281
|
+
} else {
|
2282
|
+
source += 'return buffer;\n';
|
1971
2283
|
}
|
1972
2284
|
}
|
2285
|
+
|
2286
|
+
if (varDeclarations) {
|
2287
|
+
source = 'var ' + varDeclarations.substring(2) + (appendFirst ? '' : ';\n ') + source;
|
2288
|
+
}
|
2289
|
+
|
1973
2290
|
return source;
|
1974
2291
|
},
|
1975
2292
|
|
@@ -1979,19 +2296,19 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
1979
2296
|
// On stack, after: return value of blockHelperMissing
|
1980
2297
|
//
|
1981
2298
|
// The purpose of this opcode is to take a block of the form
|
1982
|
-
// `{{#foo}}...{{/foo}}`, resolve the value of `foo`, and
|
2299
|
+
// `{{#this.foo}}...{{/this.foo}}`, resolve the value of `foo`, and
|
1983
2300
|
// replace it on the stack with the result of properly
|
1984
2301
|
// invoking blockHelperMissing.
|
1985
|
-
blockValue: function() {
|
1986
|
-
this.
|
2302
|
+
blockValue: function(name) {
|
2303
|
+
this.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
|
1987
2304
|
|
1988
|
-
var params = [
|
1989
|
-
this.setupParams(0, params);
|
2305
|
+
var params = [this.contextName(0)];
|
2306
|
+
this.setupParams(name, 0, params);
|
1990
2307
|
|
1991
|
-
this.
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
2308
|
+
var blockName = this.popStack();
|
2309
|
+
params.splice(1, 0, blockName);
|
2310
|
+
|
2311
|
+
this.push('blockHelperMissing.call(' + params.join(', ') + ')');
|
1995
2312
|
},
|
1996
2313
|
|
1997
2314
|
// [ambiguousBlockValue]
|
@@ -2001,10 +2318,13 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2001
2318
|
// On stack, after, if no lastHelper: same as [blockValue]
|
2002
2319
|
// On stack, after, if lastHelper: value
|
2003
2320
|
ambiguousBlockValue: function() {
|
2004
|
-
this.
|
2321
|
+
this.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
|
2005
2322
|
|
2006
|
-
|
2007
|
-
this.
|
2323
|
+
// We're being a bit cheeky and reusing the options value from the prior exec
|
2324
|
+
var params = [this.contextName(0)];
|
2325
|
+
this.setupParams('', 0, params, true);
|
2326
|
+
|
2327
|
+
this.flushInline();
|
2008
2328
|
|
2009
2329
|
var current = this.topStack();
|
2010
2330
|
params.splice(1, 0, current);
|
@@ -2022,27 +2342,10 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2022
2342
|
if (this.pendingContent) {
|
2023
2343
|
content = this.pendingContent + content;
|
2024
2344
|
}
|
2025
|
-
if (this.stripNext) {
|
2026
|
-
content = content.replace(/^\s+/, '');
|
2027
|
-
}
|
2028
2345
|
|
2029
2346
|
this.pendingContent = content;
|
2030
2347
|
},
|
2031
2348
|
|
2032
|
-
// [strip]
|
2033
|
-
//
|
2034
|
-
// On stack, before: ...
|
2035
|
-
// On stack, after: ...
|
2036
|
-
//
|
2037
|
-
// Removes any trailing whitespace from the prior content node and flags
|
2038
|
-
// the next operation for stripping if it is a content node.
|
2039
|
-
strip: function() {
|
2040
|
-
if (this.pendingContent) {
|
2041
|
-
this.pendingContent = this.pendingContent.replace(/\s+$/, '');
|
2042
|
-
}
|
2043
|
-
this.stripNext = 'strip';
|
2044
|
-
},
|
2045
|
-
|
2046
2349
|
// [append]
|
2047
2350
|
//
|
2048
2351
|
// On stack, before: value, ...
|
@@ -2057,7 +2360,7 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2057
2360
|
// when we examine local
|
2058
2361
|
this.flushInline();
|
2059
2362
|
var local = this.popStack();
|
2060
|
-
this.pushSource(
|
2363
|
+
this.pushSource('if (' + local + ' != null) { ' + this.appendToBuffer(local) + ' }');
|
2061
2364
|
if (this.environment.isSimple) {
|
2062
2365
|
this.pushSource("else { " + this.appendToBuffer("''") + " }");
|
2063
2366
|
}
|
@@ -2070,7 +2373,7 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2070
2373
|
//
|
2071
2374
|
// Escape `value` and append it to the buffer
|
2072
2375
|
appendEscaped: function() {
|
2073
|
-
this.
|
2376
|
+
this.aliases.escapeExpression = 'this.escapeExpression';
|
2074
2377
|
|
2075
2378
|
this.pushSource(this.appendToBuffer("escapeExpression(" + this.popStack() + ")"));
|
2076
2379
|
},
|
@@ -2083,9 +2386,17 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2083
2386
|
//
|
2084
2387
|
// Set the value of the `lastContext` compiler value to the depth
|
2085
2388
|
getContext: function(depth) {
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2389
|
+
this.lastContext = depth;
|
2390
|
+
},
|
2391
|
+
|
2392
|
+
// [pushContext]
|
2393
|
+
//
|
2394
|
+
// On stack, before: ...
|
2395
|
+
// On stack, after: currentContext, ...
|
2396
|
+
//
|
2397
|
+
// Pushes the value of the current context onto the stack.
|
2398
|
+
pushContext: function() {
|
2399
|
+
this.pushStackLiteral(this.contextName(this.lastContext));
|
2089
2400
|
},
|
2090
2401
|
|
2091
2402
|
// [lookupOnContext]
|
@@ -2095,18 +2406,54 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2095
2406
|
//
|
2096
2407
|
// Looks up the value of `name` on the current context and pushes
|
2097
2408
|
// it onto the stack.
|
2098
|
-
lookupOnContext: function(
|
2099
|
-
|
2409
|
+
lookupOnContext: function(parts, falsy, scoped) {
|
2410
|
+
/*jshint -W083 */
|
2411
|
+
var i = 0,
|
2412
|
+
len = parts.length;
|
2413
|
+
|
2414
|
+
if (!scoped && this.options.compat && !this.lastContext) {
|
2415
|
+
// The depthed query is expected to handle the undefined logic for the root level that
|
2416
|
+
// is implemented below, so we evaluate that directly in compat mode
|
2417
|
+
this.push(this.depthedLookup(parts[i++]));
|
2418
|
+
} else {
|
2419
|
+
this.pushContext();
|
2420
|
+
}
|
2421
|
+
|
2422
|
+
for (; i < len; i++) {
|
2423
|
+
this.replaceStack(function(current) {
|
2424
|
+
var lookup = this.nameLookup(current, parts[i], 'context');
|
2425
|
+
// We want to ensure that zero and false are handled properly if the context (falsy flag)
|
2426
|
+
// needs to have the special handling for these values.
|
2427
|
+
if (!falsy) {
|
2428
|
+
return ' != null ? ' + lookup + ' : ' + current;
|
2429
|
+
} else {
|
2430
|
+
// Otherwise we can use generic falsy handling
|
2431
|
+
return ' && ' + lookup;
|
2432
|
+
}
|
2433
|
+
});
|
2434
|
+
}
|
2100
2435
|
},
|
2101
2436
|
|
2102
|
-
// [
|
2437
|
+
// [lookupData]
|
2103
2438
|
//
|
2104
2439
|
// On stack, before: ...
|
2105
|
-
// On stack, after:
|
2440
|
+
// On stack, after: data, ...
|
2106
2441
|
//
|
2107
|
-
//
|
2108
|
-
|
2109
|
-
|
2442
|
+
// Push the data lookup operator
|
2443
|
+
lookupData: function(depth, parts) {
|
2444
|
+
/*jshint -W083 */
|
2445
|
+
if (!depth) {
|
2446
|
+
this.pushStackLiteral('data');
|
2447
|
+
} else {
|
2448
|
+
this.pushStackLiteral('this.data(data, ' + depth + ')');
|
2449
|
+
}
|
2450
|
+
|
2451
|
+
var len = parts.length;
|
2452
|
+
for (var i = 0; i < len; i++) {
|
2453
|
+
this.replaceStack(function(current) {
|
2454
|
+
return ' && ' + this.nameLookup(current, parts[i], 'data');
|
2455
|
+
});
|
2456
|
+
}
|
2110
2457
|
},
|
2111
2458
|
|
2112
2459
|
// [resolvePossibleLambda]
|
@@ -2117,34 +2464,9 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2117
2464
|
// If the `value` is a lambda, replace it on the stack by
|
2118
2465
|
// the return value of the lambda
|
2119
2466
|
resolvePossibleLambda: function() {
|
2120
|
-
this.
|
2467
|
+
this.aliases.lambda = 'this.lambda';
|
2121
2468
|
|
2122
|
-
this.
|
2123
|
-
return "typeof " + current + " === functionType ? " + current + ".apply(depth0) : " + current;
|
2124
|
-
});
|
2125
|
-
},
|
2126
|
-
|
2127
|
-
// [lookup]
|
2128
|
-
//
|
2129
|
-
// On stack, before: value, ...
|
2130
|
-
// On stack, after: value[name], ...
|
2131
|
-
//
|
2132
|
-
// Replace the value on the stack with the result of looking
|
2133
|
-
// up `name` on `value`
|
2134
|
-
lookup: function(name) {
|
2135
|
-
this.replaceStack(function(current) {
|
2136
|
-
return current + " == null || " + current + " === false ? " + current + " : " + this.nameLookup(current, name, 'context');
|
2137
|
-
});
|
2138
|
-
},
|
2139
|
-
|
2140
|
-
// [lookupData]
|
2141
|
-
//
|
2142
|
-
// On stack, before: ...
|
2143
|
-
// On stack, after: data, ...
|
2144
|
-
//
|
2145
|
-
// Push the data lookup operator
|
2146
|
-
lookupData: function() {
|
2147
|
-
this.pushStackLiteral('data');
|
2469
|
+
this.push('lambda(' + this.popStack() + ', ' + this.contextName(0) + ')');
|
2148
2470
|
},
|
2149
2471
|
|
2150
2472
|
// [pushStringParam]
|
@@ -2156,8 +2478,7 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2156
2478
|
// provides the string value of a parameter along with its
|
2157
2479
|
// depth rather than resolving it immediately.
|
2158
2480
|
pushStringParam: function(string, type) {
|
2159
|
-
this.
|
2160
|
-
|
2481
|
+
this.pushContext();
|
2161
2482
|
this.pushString(type);
|
2162
2483
|
|
2163
2484
|
// If it's a subexpression, the string result
|
@@ -2174,7 +2495,10 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2174
2495
|
emptyHash: function() {
|
2175
2496
|
this.pushStackLiteral('{}');
|
2176
2497
|
|
2177
|
-
if (this.
|
2498
|
+
if (this.trackIds) {
|
2499
|
+
this.push('{}'); // hashIds
|
2500
|
+
}
|
2501
|
+
if (this.stringParams) {
|
2178
2502
|
this.push('{}'); // hashContexts
|
2179
2503
|
this.push('{}'); // hashTypes
|
2180
2504
|
}
|
@@ -2183,13 +2507,16 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2183
2507
|
if (this.hash) {
|
2184
2508
|
this.hashes.push(this.hash);
|
2185
2509
|
}
|
2186
|
-
this.hash = {values: [], types: [], contexts: []};
|
2510
|
+
this.hash = {values: [], types: [], contexts: [], ids: []};
|
2187
2511
|
},
|
2188
2512
|
popHash: function() {
|
2189
2513
|
var hash = this.hash;
|
2190
2514
|
this.hash = this.hashes.pop();
|
2191
2515
|
|
2192
|
-
if (this.
|
2516
|
+
if (this.trackIds) {
|
2517
|
+
this.push('{' + hash.ids.join(',') + '}');
|
2518
|
+
}
|
2519
|
+
if (this.stringParams) {
|
2193
2520
|
this.push('{' + hash.contexts.join(',') + '}');
|
2194
2521
|
this.push('{' + hash.types.join(',') + '}');
|
2195
2522
|
}
|
@@ -2255,31 +2582,14 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2255
2582
|
// and pushes the helper's return value onto the stack.
|
2256
2583
|
//
|
2257
2584
|
// If the helper is not found, `helperMissing` is called.
|
2258
|
-
invokeHelper: function(paramSize, name,
|
2259
|
-
this.
|
2260
|
-
this.useRegister('helper');
|
2585
|
+
invokeHelper: function(paramSize, name, isSimple) {
|
2586
|
+
this.aliases.helperMissing = 'helpers.helperMissing';
|
2261
2587
|
|
2262
|
-
var
|
2263
|
-
var
|
2264
|
-
|
2265
|
-
var lookup = 'helper = ' + helper.name + ' || ' + nonHelper;
|
2266
|
-
if (helper.paramsInit) {
|
2267
|
-
lookup += ',' + helper.paramsInit;
|
2268
|
-
}
|
2269
|
-
|
2270
|
-
this.push(
|
2271
|
-
'('
|
2272
|
-
+ lookup
|
2273
|
-
+ ',helper '
|
2274
|
-
+ '? helper.call(' + helper.callParams + ') '
|
2275
|
-
+ ': helperMissing.call(' + helper.helperMissingParams + '))');
|
2588
|
+
var nonHelper = this.popStack();
|
2589
|
+
var helper = this.setupHelper(paramSize, name);
|
2276
2590
|
|
2277
|
-
|
2278
|
-
|
2279
|
-
// due to the incorrect options object being passed due to the shared register.
|
2280
|
-
if (!isRoot) {
|
2281
|
-
this.flushInline();
|
2282
|
-
}
|
2591
|
+
var lookup = (isSimple ? helper.name + ' || ' : '') + nonHelper + ' || helperMissing';
|
2592
|
+
this.push('((' + lookup + ').call(' + helper.callParams + '))');
|
2283
2593
|
},
|
2284
2594
|
|
2285
2595
|
// [invokeKnownHelper]
|
@@ -2307,22 +2617,21 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2307
2617
|
// and can be avoided by passing the `knownHelpers` and
|
2308
2618
|
// `knownHelpersOnly` flags at compile-time.
|
2309
2619
|
invokeAmbiguous: function(name, helperCall) {
|
2310
|
-
this.
|
2620
|
+
this.aliases.functionType = '"function"';
|
2621
|
+
this.aliases.helperMissing = 'helpers.helperMissing';
|
2311
2622
|
this.useRegister('helper');
|
2312
2623
|
|
2624
|
+
var nonHelper = this.popStack();
|
2625
|
+
|
2313
2626
|
this.emptyHash();
|
2314
2627
|
var helper = this.setupHelper(0, name, helperCall);
|
2315
2628
|
|
2316
2629
|
var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper');
|
2317
2630
|
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
this.pushSource(helper.paramsInit);
|
2323
|
-
}
|
2324
|
-
this.pushSource('if (helper = ' + helperName + ') { ' + nextStack + ' = helper.call(' + helper.callParams + '); }');
|
2325
|
-
this.pushSource('else { helper = ' + nonHelper + '; ' + nextStack + ' = typeof helper === functionType ? helper.call(' + helper.callParams + ') : helper; }');
|
2631
|
+
this.push(
|
2632
|
+
'((helper = (helper = ' + helperName + ' || ' + nonHelper + ') != null ? helper : helperMissing'
|
2633
|
+
+ (helper.paramsInit ? '),(' + helper.paramsInit : '') + '),'
|
2634
|
+
+ '(typeof helper === functionType ? helper.call(' + helper.callParams + ') : helper))');
|
2326
2635
|
},
|
2327
2636
|
|
2328
2637
|
// [invokePartial]
|
@@ -2332,30 +2641,37 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2332
2641
|
//
|
2333
2642
|
// This operation pops off a context, invokes a partial with that context,
|
2334
2643
|
// and pushes the result of the invocation back.
|
2335
|
-
invokePartial: function(name) {
|
2336
|
-
var params = [this.nameLookup('partials', name, 'partial'), "'" + name + "'", this.popStack(), "helpers", "partials"];
|
2644
|
+
invokePartial: function(name, indent) {
|
2645
|
+
var params = [this.nameLookup('partials', name, 'partial'), "'" + indent + "'", "'" + name + "'", this.popStack(), this.popStack(), "helpers", "partials"];
|
2337
2646
|
|
2338
2647
|
if (this.options.data) {
|
2339
2648
|
params.push("data");
|
2649
|
+
} else if (this.options.compat) {
|
2650
|
+
params.push('undefined');
|
2651
|
+
}
|
2652
|
+
if (this.options.compat) {
|
2653
|
+
params.push('depths');
|
2340
2654
|
}
|
2341
2655
|
|
2342
|
-
this.
|
2343
|
-
this.push("self.invokePartial(" + params.join(", ") + ")");
|
2656
|
+
this.push("this.invokePartial(" + params.join(", ") + ")");
|
2344
2657
|
},
|
2345
2658
|
|
2346
2659
|
// [assignToHash]
|
2347
2660
|
//
|
2348
|
-
// On stack, before: value, hash, ...
|
2349
|
-
// On stack, after: hash, ...
|
2661
|
+
// On stack, before: value, ..., hash, ...
|
2662
|
+
// On stack, after: ..., hash, ...
|
2350
2663
|
//
|
2351
|
-
// Pops a value
|
2352
|
-
// and pushes the hash back onto the stack.
|
2664
|
+
// Pops a value off the stack and assigns it to the current hash
|
2353
2665
|
assignToHash: function(key) {
|
2354
2666
|
var value = this.popStack(),
|
2355
2667
|
context,
|
2356
|
-
type
|
2668
|
+
type,
|
2669
|
+
id;
|
2357
2670
|
|
2358
|
-
if (this.
|
2671
|
+
if (this.trackIds) {
|
2672
|
+
id = this.popStack();
|
2673
|
+
}
|
2674
|
+
if (this.stringParams) {
|
2359
2675
|
type = this.popStack();
|
2360
2676
|
context = this.popStack();
|
2361
2677
|
}
|
@@ -2367,9 +2683,22 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2367
2683
|
if (type) {
|
2368
2684
|
hash.types.push("'" + key + "': " + type);
|
2369
2685
|
}
|
2686
|
+
if (id) {
|
2687
|
+
hash.ids.push("'" + key + "': " + id);
|
2688
|
+
}
|
2370
2689
|
hash.values.push("'" + key + "': (" + value + ")");
|
2371
2690
|
},
|
2372
2691
|
|
2692
|
+
pushId: function(type, name) {
|
2693
|
+
if (type === 'ID' || type === 'DATA') {
|
2694
|
+
this.pushString(name);
|
2695
|
+
} else if (type === 'sexpr') {
|
2696
|
+
this.pushStackLiteral('true');
|
2697
|
+
} else {
|
2698
|
+
this.pushStackLiteral('null');
|
2699
|
+
}
|
2700
|
+
},
|
2701
|
+
|
2373
2702
|
// HELPERS
|
2374
2703
|
|
2375
2704
|
compiler: JavaScriptCompiler,
|
@@ -2388,8 +2717,10 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2388
2717
|
index = this.context.programs.length;
|
2389
2718
|
child.index = index;
|
2390
2719
|
child.name = 'program' + index;
|
2391
|
-
this.context.programs[index] = compiler.compile(child, options, this.context);
|
2720
|
+
this.context.programs[index] = compiler.compile(child, options, this.context, !this.precompile);
|
2392
2721
|
this.context.environments[index] = child;
|
2722
|
+
|
2723
|
+
this.useDepths = this.useDepths || compiler.useDepths;
|
2393
2724
|
} else {
|
2394
2725
|
child.index = index;
|
2395
2726
|
child.name = 'program' + index;
|
@@ -2406,30 +2737,18 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2406
2737
|
},
|
2407
2738
|
|
2408
2739
|
programExpression: function(guid) {
|
2409
|
-
this.context.aliases.self = "this";
|
2410
|
-
|
2411
|
-
if(guid == null) {
|
2412
|
-
return "self.noop";
|
2413
|
-
}
|
2414
|
-
|
2415
2740
|
var child = this.environment.children[guid],
|
2416
|
-
depths = child.depths.list,
|
2417
|
-
|
2418
|
-
|
2741
|
+
depths = child.depths.list,
|
2742
|
+
useDepths = this.useDepths,
|
2743
|
+
depth;
|
2419
2744
|
|
2420
|
-
|
2421
|
-
depth = depths[i];
|
2745
|
+
var programParams = [child.index, 'data'];
|
2422
2746
|
|
2423
|
-
|
2424
|
-
|
2747
|
+
if (useDepths) {
|
2748
|
+
programParams.push('depths');
|
2425
2749
|
}
|
2426
2750
|
|
2427
|
-
return
|
2428
|
-
},
|
2429
|
-
|
2430
|
-
register: function(name, val) {
|
2431
|
-
this.useRegister(name);
|
2432
|
-
this.pushSource(name + " = " + val + ";");
|
2751
|
+
return 'this.program(' + programParams.join(', ') + ')';
|
2433
2752
|
},
|
2434
2753
|
|
2435
2754
|
useRegister: function(name) {
|
@@ -2458,9 +2777,7 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2458
2777
|
this.flushInline();
|
2459
2778
|
|
2460
2779
|
var stack = this.incrStack();
|
2461
|
-
|
2462
|
-
this.pushSource(stack + " = " + item + ";");
|
2463
|
-
}
|
2780
|
+
this.pushSource(stack + " = " + item + ";");
|
2464
2781
|
this.compileStack.push(stack);
|
2465
2782
|
return stack;
|
2466
2783
|
},
|
@@ -2472,50 +2789,36 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2472
2789
|
createdStack,
|
2473
2790
|
usedLiteral;
|
2474
2791
|
|
2475
|
-
|
2476
|
-
|
2477
|
-
|
2478
|
-
|
2792
|
+
/* istanbul ignore next */
|
2793
|
+
if (!this.isInline()) {
|
2794
|
+
throw new Exception('replaceStack on non-inline');
|
2795
|
+
}
|
2479
2796
|
|
2480
|
-
|
2481
|
-
|
2482
|
-
stack = top.value;
|
2483
|
-
usedLiteral = true;
|
2484
|
-
} else {
|
2485
|
-
// Get or create the current stack name for use by the inline
|
2486
|
-
createdStack = !this.stackSlot;
|
2487
|
-
var name = !createdStack ? this.topStackName() : this.incrStack();
|
2797
|
+
// We want to merge the inline statement into the replacement statement via ','
|
2798
|
+
var top = this.popStack(true);
|
2488
2799
|
|
2489
|
-
|
2490
|
-
|
2491
|
-
|
2800
|
+
if (top instanceof Literal) {
|
2801
|
+
// Literals do not need to be inlined
|
2802
|
+
prefix = stack = top.value;
|
2803
|
+
usedLiteral = true;
|
2492
2804
|
} else {
|
2805
|
+
// Get or create the current stack name for use by the inline
|
2806
|
+
createdStack = !this.stackSlot;
|
2807
|
+
var name = !createdStack ? this.topStackName() : this.incrStack();
|
2808
|
+
|
2809
|
+
prefix = '(' + this.push(name) + ' = ' + top + ')';
|
2493
2810
|
stack = this.topStack();
|
2494
2811
|
}
|
2495
2812
|
|
2496
2813
|
var item = callback.call(this, stack);
|
2497
2814
|
|
2498
|
-
if (
|
2499
|
-
|
2500
|
-
this.popStack();
|
2501
|
-
}
|
2502
|
-
if (createdStack) {
|
2503
|
-
this.stackSlot--;
|
2504
|
-
}
|
2505
|
-
this.push('(' + prefix + item + ')');
|
2506
|
-
} else {
|
2507
|
-
// Prevent modification of the context depth variable. Through replaceStack
|
2508
|
-
if (!/^stack/.test(stack)) {
|
2509
|
-
stack = this.nextStack();
|
2510
|
-
}
|
2511
|
-
|
2512
|
-
this.pushSource(stack + " = (" + prefix + item + ");");
|
2815
|
+
if (!usedLiteral) {
|
2816
|
+
this.popStack();
|
2513
2817
|
}
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2517
|
-
|
2518
|
-
return this.pushStack();
|
2818
|
+
if (createdStack) {
|
2819
|
+
this.stackSlot--;
|
2820
|
+
}
|
2821
|
+
this.push('(' + prefix + item + ')');
|
2519
2822
|
},
|
2520
2823
|
|
2521
2824
|
incrStack: function() {
|
@@ -2552,6 +2855,7 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2552
2855
|
return item.value;
|
2553
2856
|
} else {
|
2554
2857
|
if (!inline) {
|
2858
|
+
/* istanbul ignore next */
|
2555
2859
|
if (!this.stackSlot) {
|
2556
2860
|
throw new Exception('Invalid stack pop');
|
2557
2861
|
}
|
@@ -2561,17 +2865,25 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2561
2865
|
}
|
2562
2866
|
},
|
2563
2867
|
|
2564
|
-
topStack: function(
|
2868
|
+
topStack: function() {
|
2565
2869
|
var stack = (this.isInline() ? this.inlineStack : this.compileStack),
|
2566
2870
|
item = stack[stack.length - 1];
|
2567
2871
|
|
2568
|
-
if (
|
2872
|
+
if (item instanceof Literal) {
|
2569
2873
|
return item.value;
|
2570
2874
|
} else {
|
2571
2875
|
return item;
|
2572
2876
|
}
|
2573
2877
|
},
|
2574
2878
|
|
2879
|
+
contextName: function(context) {
|
2880
|
+
if (this.useDepths && context) {
|
2881
|
+
return 'depths[' + context + ']';
|
2882
|
+
} else {
|
2883
|
+
return 'depth' + context;
|
2884
|
+
}
|
2885
|
+
},
|
2886
|
+
|
2575
2887
|
quotedString: function(str) {
|
2576
2888
|
return '"' + str
|
2577
2889
|
.replace(/\\/g, '\\\\')
|
@@ -2582,28 +2894,43 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2582
2894
|
.replace(/\u2029/g, '\\u2029') + '"';
|
2583
2895
|
},
|
2584
2896
|
|
2585
|
-
|
2897
|
+
objectLiteral: function(obj) {
|
2898
|
+
var pairs = [];
|
2899
|
+
|
2900
|
+
for (var key in obj) {
|
2901
|
+
if (obj.hasOwnProperty(key)) {
|
2902
|
+
pairs.push(this.quotedString(key) + ':' + obj[key]);
|
2903
|
+
}
|
2904
|
+
}
|
2905
|
+
|
2906
|
+
return '{' + pairs.join(',') + '}';
|
2907
|
+
},
|
2908
|
+
|
2909
|
+
setupHelper: function(paramSize, name, blockHelper) {
|
2586
2910
|
var params = [],
|
2587
|
-
paramsInit = this.setupParams(paramSize, params,
|
2911
|
+
paramsInit = this.setupParams(name, paramSize, params, blockHelper);
|
2588
2912
|
var foundHelper = this.nameLookup('helpers', name, 'helper');
|
2589
2913
|
|
2590
2914
|
return {
|
2591
2915
|
params: params,
|
2592
2916
|
paramsInit: paramsInit,
|
2593
2917
|
name: foundHelper,
|
2594
|
-
callParams: [
|
2595
|
-
helperMissingParams: missingParams && ["depth0", this.quotedString(name)].concat(params).join(", ")
|
2918
|
+
callParams: [this.contextName(0)].concat(params).join(", ")
|
2596
2919
|
};
|
2597
2920
|
},
|
2598
2921
|
|
2599
|
-
setupOptions: function(paramSize, params) {
|
2600
|
-
var options =
|
2922
|
+
setupOptions: function(helper, paramSize, params) {
|
2923
|
+
var options = {}, contexts = [], types = [], ids = [], param, inverse, program;
|
2601
2924
|
|
2602
|
-
options.
|
2925
|
+
options.name = this.quotedString(helper);
|
2926
|
+
options.hash = this.popStack();
|
2603
2927
|
|
2604
|
-
if (this.
|
2605
|
-
options.
|
2606
|
-
|
2928
|
+
if (this.trackIds) {
|
2929
|
+
options.hashIds = this.popStack();
|
2930
|
+
}
|
2931
|
+
if (this.stringParams) {
|
2932
|
+
options.hashTypes = this.popStack();
|
2933
|
+
options.hashContexts = this.popStack();
|
2607
2934
|
}
|
2608
2935
|
|
2609
2936
|
inverse = this.popStack();
|
@@ -2613,36 +2940,43 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2613
2940
|
// helpers to do a check for `if (options.fn)`
|
2614
2941
|
if (program || inverse) {
|
2615
2942
|
if (!program) {
|
2616
|
-
|
2617
|
-
program = "self.noop";
|
2943
|
+
program = 'this.noop';
|
2618
2944
|
}
|
2619
2945
|
|
2620
2946
|
if (!inverse) {
|
2621
|
-
|
2622
|
-
inverse = "self.noop";
|
2947
|
+
inverse = 'this.noop';
|
2623
2948
|
}
|
2624
2949
|
|
2625
|
-
options.
|
2626
|
-
options.
|
2950
|
+
options.fn = program;
|
2951
|
+
options.inverse = inverse;
|
2627
2952
|
}
|
2628
2953
|
|
2629
|
-
|
2954
|
+
// The parameters go on to the stack in order (making sure that they are evaluated in order)
|
2955
|
+
// so we need to pop them off the stack in reverse order
|
2956
|
+
var i = paramSize;
|
2957
|
+
while (i--) {
|
2630
2958
|
param = this.popStack();
|
2631
|
-
params
|
2959
|
+
params[i] = param;
|
2632
2960
|
|
2633
|
-
if(this.
|
2634
|
-
|
2635
|
-
|
2961
|
+
if (this.trackIds) {
|
2962
|
+
ids[i] = this.popStack();
|
2963
|
+
}
|
2964
|
+
if (this.stringParams) {
|
2965
|
+
types[i] = this.popStack();
|
2966
|
+
contexts[i] = this.popStack();
|
2636
2967
|
}
|
2637
2968
|
}
|
2638
2969
|
|
2639
|
-
if (this.
|
2640
|
-
options.
|
2641
|
-
|
2970
|
+
if (this.trackIds) {
|
2971
|
+
options.ids = "[" + ids.join(",") + "]";
|
2972
|
+
}
|
2973
|
+
if (this.stringParams) {
|
2974
|
+
options.types = "[" + types.join(",") + "]";
|
2975
|
+
options.contexts = "[" + contexts.join(",") + "]";
|
2642
2976
|
}
|
2643
2977
|
|
2644
|
-
if(this.options.data) {
|
2645
|
-
options.
|
2978
|
+
if (this.options.data) {
|
2979
|
+
options.data = "data";
|
2646
2980
|
}
|
2647
2981
|
|
2648
2982
|
return options;
|
@@ -2650,8 +2984,8 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2650
2984
|
|
2651
2985
|
// the params and contexts arguments are passed in arrays
|
2652
2986
|
// to fill in
|
2653
|
-
setupParams: function(paramSize, params, useRegister) {
|
2654
|
-
var options =
|
2987
|
+
setupParams: function(helperName, paramSize, params, useRegister) {
|
2988
|
+
var options = this.objectLiteral(this.setupOptions(helperName, paramSize, params));
|
2655
2989
|
|
2656
2990
|
if (useRegister) {
|
2657
2991
|
this.useRegister('options');
|
@@ -2689,10 +3023,7 @@ var __module11__ = (function(__dependency1__, __dependency2__) {
|
|
2689
3023
|
}
|
2690
3024
|
|
2691
3025
|
JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
|
2692
|
-
|
2693
|
-
return true;
|
2694
|
-
}
|
2695
|
-
return false;
|
3026
|
+
return !JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(name);
|
2696
3027
|
};
|
2697
3028
|
|
2698
3029
|
__exports__ = JavaScriptCompiler;
|
@@ -2738,9 +3069,11 @@ var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, _
|
|
2738
3069
|
Handlebars = create();
|
2739
3070
|
Handlebars.create = create;
|
2740
3071
|
|
3072
|
+
Handlebars['default'] = Handlebars;
|
3073
|
+
|
2741
3074
|
__exports__ = Handlebars;
|
2742
3075
|
return __exports__;
|
2743
|
-
})(__module1__, __module7__, __module8__,
|
3076
|
+
})(__module1__, __module7__, __module8__, __module11__, __module12__);
|
2744
3077
|
|
2745
3078
|
return __module0__;
|
2746
|
-
})
|
3079
|
+
}));
|