handlebars_assets 0.18 → 0.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
 
3
- handlebars v2.0.0
3
+ handlebars v3.0.0
4
4
 
5
5
  Copyright (C) 2011-2014 by Yehuda Katz
6
6
 
@@ -25,39 +25,24 @@ THE SOFTWARE.
25
25
  @license
26
26
  */
27
27
  /* exported Handlebars */
28
+ if (!window) {
29
+ var window = {};
30
+ }
31
+
28
32
  (function (root, factory) {
29
33
  if (typeof define === 'function' && define.amd) {
30
34
  define([], factory);
31
35
  } else if (typeof exports === 'object') {
32
36
  module.exports = factory();
33
37
  } else {
34
- root.Handlebars = root.Handlebars || factory();
38
+ root.Handlebars = factory();
35
39
  }
36
40
  }(this, function () {
37
- // handlebars/safe-string.js
38
- var __module3__ = (function() {
39
- "use strict";
40
- var __exports__;
41
- // Build out our basic SafeString type
42
- function SafeString(string) {
43
- this.string = string;
44
- }
45
-
46
- SafeString.prototype.toString = function() {
47
- return "" + this.string;
48
- };
49
-
50
- __exports__ = SafeString;
51
- return __exports__;
52
- })();
53
-
54
41
  // handlebars/utils.js
55
- var __module2__ = (function(__dependency1__) {
42
+ var __module2__ = (function() {
56
43
  "use strict";
57
44
  var __exports__ = {};
58
45
  /*jshint -W004 */
59
- var SafeString = __dependency1__;
60
-
61
46
  var escape = {
62
47
  "&": "&",
63
48
  "<": "&lt;",
@@ -107,11 +92,21 @@ var __module2__ = (function(__dependency1__) {
107
92
  return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
108
93
  };
109
94
  __exports__.isArray = isArray;
95
+ // Older IE versions do not directly support indexOf so we must implement our own, sadly.
96
+ function indexOf(array, value) {
97
+ for (var i = 0, len = array.length; i < len; i++) {
98
+ if (array[i] === value) {
99
+ return i;
100
+ }
101
+ }
102
+ return -1;
103
+ }
110
104
 
105
+ __exports__.indexOf = indexOf;
111
106
  function escapeExpression(string) {
112
107
  // don't escape SafeStrings, since they're already safe
113
- if (string instanceof SafeString) {
114
- return string.toString();
108
+ if (string && string.toHTML) {
109
+ return string.toHTML();
115
110
  } else if (string == null) {
116
111
  return "";
117
112
  } else if (!string) {
@@ -137,27 +132,35 @@ var __module2__ = (function(__dependency1__) {
137
132
  }
138
133
  }
139
134
 
140
- __exports__.isEmpty = isEmpty;function appendContextPath(contextPath, id) {
135
+ __exports__.isEmpty = isEmpty;function blockParams(params, ids) {
136
+ params.path = ids;
137
+ return params;
138
+ }
139
+
140
+ __exports__.blockParams = blockParams;function appendContextPath(contextPath, id) {
141
141
  return (contextPath ? contextPath + '.' : '') + id;
142
142
  }
143
143
 
144
144
  __exports__.appendContextPath = appendContextPath;
145
145
  return __exports__;
146
- })(__module3__);
146
+ })();
147
147
 
148
148
  // handlebars/exception.js
149
- var __module4__ = (function() {
149
+ var __module3__ = (function() {
150
150
  "use strict";
151
151
  var __exports__;
152
152
 
153
153
  var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
154
154
 
155
155
  function Exception(message, node) {
156
- var line;
157
- if (node && node.firstLine) {
158
- line = node.firstLine;
159
-
160
- message += ' - ' + line + ':' + node.firstColumn;
156
+ var loc = node && node.loc,
157
+ line,
158
+ column;
159
+ if (loc) {
160
+ line = loc.start.line;
161
+ column = loc.start.column;
162
+
163
+ message += ' - ' + line + ':' + column;
161
164
  }
162
165
 
163
166
  var tmp = Error.prototype.constructor.call(this, message);
@@ -167,9 +170,9 @@ var __module4__ = (function() {
167
170
  this[errorProps[idx]] = tmp[errorProps[idx]];
168
171
  }
169
172
 
170
- if (line) {
173
+ if (loc) {
171
174
  this.lineNumber = line;
172
- this.column = node.firstColumn;
175
+ this.column = column;
173
176
  }
174
177
  }
175
178
 
@@ -186,7 +189,7 @@ var __module1__ = (function(__dependency1__, __dependency2__) {
186
189
  var Utils = __dependency1__;
187
190
  var Exception = __dependency2__;
188
191
 
189
- var VERSION = "2.0.0";
192
+ var VERSION = "3.0.0";
190
193
  __exports__.VERSION = VERSION;var COMPILER_REVISION = 6;
191
194
  __exports__.COMPILER_REVISION = COMPILER_REVISION;
192
195
  var REVISION_CHANGES = {
@@ -232,6 +235,9 @@ var __module1__ = (function(__dependency1__, __dependency2__) {
232
235
  if (toString.call(name) === objectType) {
233
236
  Utils.extend(this.partials, name);
234
237
  } else {
238
+ if (typeof partial === 'undefined') {
239
+ throw new Exception('Attempting to register a partial as undefined');
240
+ }
235
241
  this.partials[name] = partial;
236
242
  }
237
243
  },
@@ -299,36 +305,47 @@ var __module1__ = (function(__dependency1__, __dependency2__) {
299
305
  data = createFrame(options.data);
300
306
  }
301
307
 
308
+ function execIteration(key, i, last) {
309
+ if (data) {
310
+ data.key = key;
311
+ data.index = i;
312
+ data.first = i === 0;
313
+ data.last = !!last;
314
+
315
+ if (contextPath) {
316
+ data.contextPath = contextPath + key;
317
+ }
318
+ }
319
+
320
+ ret = ret + fn(context[key], {
321
+ data: data,
322
+ blockParams: Utils.blockParams([context[key], key], [contextPath + key, null])
323
+ });
324
+ }
325
+
302
326
  if(context && typeof context === 'object') {
303
327
  if (isArray(context)) {
304
328
  for(var j = context.length; i<j; i++) {
305
- if (data) {
306
- data.index = i;
307
- data.first = (i === 0);
308
- data.last = (i === (context.length-1));
309
-
310
- if (contextPath) {
311
- data.contextPath = contextPath + i;
312
- }
313
- }
314
- ret = ret + fn(context[i], { data: data });
329
+ execIteration(i, i, i === context.length-1);
315
330
  }
316
331
  } else {
332
+ var priorKey;
333
+
317
334
  for(var key in context) {
318
335
  if(context.hasOwnProperty(key)) {
319
- if(data) {
320
- data.key = key;
321
- data.index = i;
322
- data.first = (i === 0);
323
-
324
- if (contextPath) {
325
- data.contextPath = contextPath + key;
326
- }
336
+ // We're running the iterations one step out of sync so we can detect
337
+ // the last iteration without have to scan the object twice and create
338
+ // an itermediate keys array.
339
+ if (priorKey) {
340
+ execIteration(priorKey, i-1);
327
341
  }
328
- ret = ret + fn(context[key], {data: data});
342
+ priorKey = key;
329
343
  i++;
330
344
  }
331
345
  }
346
+ if (priorKey) {
347
+ execIteration(priorKey, i-1, true);
348
+ }
332
349
  }
333
350
  }
334
351
 
@@ -392,15 +409,13 @@ var __module1__ = (function(__dependency1__, __dependency2__) {
392
409
  INFO: 1,
393
410
  WARN: 2,
394
411
  ERROR: 3,
395
- level: 3,
412
+ level: 1,
396
413
 
397
- // can be overridden in the host environment
414
+ // Can be overridden in the host environment
398
415
  log: function(level, message) {
399
- if (logger.level <= level) {
416
+ if (typeof console !== 'undefined' && logger.level <= level) {
400
417
  var method = logger.methodMap[level];
401
- if (typeof console !== 'undefined' && console[method]) {
402
- console[method].call(console, message);
403
- }
418
+ (console[method] || console.log).call(console, message);
404
419
  }
405
420
  }
406
421
  };
@@ -414,7 +429,24 @@ var __module1__ = (function(__dependency1__, __dependency2__) {
414
429
  };
415
430
  __exports__.createFrame = createFrame;
416
431
  return __exports__;
417
- })(__module2__, __module4__);
432
+ })(__module2__, __module3__);
433
+
434
+ // handlebars/safe-string.js
435
+ var __module4__ = (function() {
436
+ "use strict";
437
+ var __exports__;
438
+ // Build out our basic SafeString type
439
+ function SafeString(string) {
440
+ this.string = string;
441
+ }
442
+
443
+ SafeString.prototype.toString = SafeString.prototype.toHTML = function() {
444
+ return "" + this.string;
445
+ };
446
+
447
+ __exports__ = SafeString;
448
+ return __exports__;
449
+ })();
418
450
 
419
451
  // handlebars/runtime.js
420
452
  var __module5__ = (function(__dependency1__, __dependency2__, __dependency3__) {
@@ -459,38 +491,44 @@ var __module5__ = (function(__dependency1__, __dependency2__, __dependency3__) {
459
491
  // for external users to override these as psuedo-supported APIs.
460
492
  env.VM.checkRevision(templateSpec.compiler);
461
493
 
462
- var invokePartialWrapper = function(partial, indent, name, context, hash, helpers, partials, data, depths) {
463
- if (hash) {
464
- context = Utils.extend({}, context, hash);
494
+ var invokePartialWrapper = function(partial, context, options) {
495
+ if (options.hash) {
496
+ context = Utils.extend({}, context, options.hash);
465
497
  }
466
498
 
467
- var result = env.VM.invokePartial.call(this, partial, name, context, helpers, partials, data, depths);
499
+ partial = env.VM.resolvePartial.call(this, partial, context, options);
500
+ var result = env.VM.invokePartial.call(this, partial, context, options);
468
501
 
469
502
  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);
503
+ options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env);
504
+ result = options.partials[options.name](context, options);
473
505
  }
474
506
  if (result != null) {
475
- if (indent) {
507
+ if (options.indent) {
476
508
  var lines = result.split('\n');
477
509
  for (var i = 0, l = lines.length; i < l; i++) {
478
510
  if (!lines[i] && i + 1 === l) {
479
511
  break;
480
512
  }
481
513
 
482
- lines[i] = indent + lines[i];
514
+ lines[i] = options.indent + lines[i];
483
515
  }
484
516
  result = lines.join('\n');
485
517
  }
486
518
  return result;
487
519
  } else {
488
- throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
520
+ throw new Exception("The partial " + options.name + " could not be compiled when running in runtime-only mode");
489
521
  }
490
522
  };
491
523
 
492
524
  // Just add water
493
525
  var container = {
526
+ strict: function(obj, name) {
527
+ if (!(name in obj)) {
528
+ throw new Exception('"' + name + '" not defined in ' + obj);
529
+ }
530
+ return obj[name];
531
+ },
494
532
  lookup: function(depths, name) {
495
533
  var len = depths.length;
496
534
  for (var i = 0; i < len; i++) {
@@ -511,11 +549,11 @@ var __module5__ = (function(__dependency1__, __dependency2__, __dependency3__) {
511
549
  },
512
550
 
513
551
  programs: [],
514
- program: function(i, data, depths) {
552
+ program: function(i, data, declaredBlockParams, blockParams, depths) {
515
553
  var programWrapper = this.programs[i],
516
554
  fn = this.fn(i);
517
- if (data || depths) {
518
- programWrapper = program(this, i, fn, data, depths);
555
+ if (data || depths || blockParams || declaredBlockParams) {
556
+ programWrapper = program(this, i, fn, data, declaredBlockParams, blockParams, depths);
519
557
  } else if (!programWrapper) {
520
558
  programWrapper = this.programs[i] = program(this, i, fn);
521
559
  }
@@ -550,12 +588,13 @@ var __module5__ = (function(__dependency1__, __dependency2__, __dependency3__) {
550
588
  if (!options.partial && templateSpec.useData) {
551
589
  data = initData(context, data);
552
590
  }
553
- var depths;
591
+ var depths,
592
+ blockParams = templateSpec.useBlockParams ? [] : undefined;
554
593
  if (templateSpec.useDepths) {
555
594
  depths = options.depths ? [context].concat(options.depths) : [context];
556
595
  }
557
596
 
558
- return templateSpec.main.call(container, context, container.helpers, container.partials, data, depths);
597
+ return templateSpec.main.call(container, context, container.helpers, container.partials, data, blockParams, depths);
559
598
  };
560
599
  ret.isTop = true;
561
600
 
@@ -572,32 +611,52 @@ var __module5__ = (function(__dependency1__, __dependency2__, __dependency3__) {
572
611
  }
573
612
  };
574
613
 
575
- ret._child = function(i, data, depths) {
614
+ ret._child = function(i, data, blockParams, depths) {
615
+ if (templateSpec.useBlockParams && !blockParams) {
616
+ throw new Exception('must pass block params');
617
+ }
576
618
  if (templateSpec.useDepths && !depths) {
577
619
  throw new Exception('must pass parent depths');
578
620
  }
579
621
 
580
- return program(container, i, templateSpec[i], data, depths);
622
+ return program(container, i, templateSpec[i], data, 0, blockParams, depths);
581
623
  };
582
624
  return ret;
583
625
  }
584
626
 
585
- __exports__.template = template;function program(container, i, fn, data, depths) {
627
+ __exports__.template = template;function program(container, i, fn, data, declaredBlockParams, blockParams, depths) {
586
628
  var prog = function(context, options) {
587
629
  options = options || {};
588
630
 
589
- return fn.call(container, context, container.helpers, container.partials, options.data || data, depths && [context].concat(depths));
631
+ return fn.call(container,
632
+ context,
633
+ container.helpers, container.partials,
634
+ options.data || data,
635
+ blockParams && [options.blockParams].concat(blockParams),
636
+ depths && [context].concat(depths));
590
637
  };
591
638
  prog.program = i;
592
639
  prog.depth = depths ? depths.length : 0;
640
+ prog.blockParams = declaredBlockParams || 0;
593
641
  return prog;
594
642
  }
595
643
 
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 };
644
+ __exports__.program = program;function resolvePartial(partial, context, options) {
645
+ if (!partial) {
646
+ partial = options.partials[options.name];
647
+ } else if (!partial.call && !options.name) {
648
+ // This is a dynamic partial that returned a string
649
+ options.name = partial;
650
+ partial = options.partials[partial];
651
+ }
652
+ return partial;
653
+ }
654
+
655
+ __exports__.resolvePartial = resolvePartial;function invokePartial(partial, context, options) {
656
+ options.partial = true;
598
657
 
599
658
  if(partial === undefined) {
600
- throw new Exception("The partial " + name + " could not be found");
659
+ throw new Exception("The partial " + options.name + " could not be found");
601
660
  } else if(partial instanceof Function) {
602
661
  return partial(context, options);
603
662
  }
@@ -613,7 +672,7 @@ var __module5__ = (function(__dependency1__, __dependency2__, __dependency3__) {
613
672
  return data;
614
673
  }
615
674
  return __exports__;
616
- })(__module2__, __module4__, __module1__);
675
+ })(__module2__, __module3__, __module1__);
617
676
 
618
677
  // handlebars.runtime.js
619
678
  var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {
@@ -650,11 +709,22 @@ var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, _
650
709
  var Handlebars = create();
651
710
  Handlebars.create = create;
652
711
 
712
+ /*jshint -W040 */
713
+ /* istanbul ignore next */
714
+ var root = typeof global !== 'undefined' ? global : window,
715
+ $Handlebars = root.Handlebars;
716
+ /* istanbul ignore next */
717
+ Handlebars.noConflict = function() {
718
+ if (root.Handlebars === Handlebars) {
719
+ root.Handlebars = $Handlebars;
720
+ }
721
+ };
722
+
653
723
  Handlebars['default'] = Handlebars;
654
724
 
655
725
  __exports__ = Handlebars;
656
726
  return __exports__;
657
- })(__module1__, __module3__, __module4__, __module2__, __module5__);
727
+ })(__module1__, __module4__, __module3__, __module2__, __module5__);
658
728
 
659
729
  return __module0__;
660
730
  }));
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handlebars_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.18'
4
+ version: '0.19'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Hill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-08 00:00:00.000000000 Z
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.2.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.2.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tilt
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: multi_json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sprockets
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 2.0.3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.0.3
69
69
  - !ruby/object:Gem::Dependency
70
- name: debugger
70
+ name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: haml
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: slim
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: json
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: 1.7.7
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.7.7
139
139
  description: Compile Handlebars templates in the Rails asset pipeline.
@@ -143,8 +143,8 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - .gitignore
147
- - .ruby-gemset
146
+ - ".gitignore"
147
+ - ".ruby-gemset"
148
148
  - CHANGELOG.md
149
149
  - Gemfile
150
150
  - MIT-LICENSE
@@ -176,17 +176,17 @@ require_paths:
176
176
  - lib
177
177
  required_ruby_version: !ruby/object:Gem::Requirement
178
178
  requirements:
179
- - - '>='
179
+ - - ">="
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - '>='
184
+ - - ">="
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  requirements: []
188
188
  rubyforge_project: handlebars_assets
189
- rubygems_version: 2.1.10
189
+ rubygems_version: 2.2.2
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: Compile Handlebars templates in the Rails asset pipeline.