handlebars-source 1.0.9 → 1.0.12

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

Potentially problematic release.


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

Files changed (4) hide show
  1. checksums.yaml +15 -0
  2. data/dist/handlebars.js +243 -151
  3. data/dist/handlebars.runtime.js +89 -31
  4. metadata +5 -7
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzlkYzQ3OGZkMjFjZjFjMGZjNjNhNTBjZTMyNDdjYzZiOGE2OTY3ZQ==
5
+ data.tar.gz: !binary |-
6
+ NDg2NWRlYmJkZWQ1MzkyNjA5OTljYzdhODY2Y2E0ODljZWRkMzY2ZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YmI5NWEwYmQzNTdjMDUzZmU1OGI4NmY3ODA3YTZjMGI0MDI4NTBhN2RmODhl
10
+ ZTc4MzViNDg1MDE3MzYzMDRjOGFjMjMwMjhmMWE4ODE4Njc3NzM5MDJkMjNj
11
+ OWE4NjFhZWM0YzhlNjc3YmQ2ZjhiOTk1MDJhOTMwMjAxYjE4OTI=
12
+ data.tar.gz: !binary |-
13
+ ZDYwYTFhZGZkOWQ2Yzc4ZDhjYmY3MTZmODcwNjE1ZGE3ZTM4YTYxMzQ3ZGQ4
14
+ MGNiNTA5MzE0YThhNjU0ZTk1ODY0OTI3MjlhNmNmYmFjMmY5OWU5Nzg4NjY2
15
+ OGY2ODQzMTkyNmVmMjkzZTU4MjYwNDQ3NzJkNGYzYjE1YjdmYjk=
@@ -20,45 +20,58 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  THE SOFTWARE.
22
22
 
23
+ @license
23
24
  */
24
25
 
25
26
  // lib/handlebars/browser-prefix.js
26
- var Handlebars = {};
27
-
28
- (function(Handlebars, undefined) {
27
+ (function(undefined) {
28
+ var Handlebars = {};
29
29
  ;
30
30
  // lib/handlebars/base.js
31
31
 
32
- Handlebars.VERSION = "1.0.0-rc.3";
33
- Handlebars.COMPILER_REVISION = 2;
32
+ Handlebars.VERSION = "1.0.0";
33
+ Handlebars.COMPILER_REVISION = 4;
34
34
 
35
35
  Handlebars.REVISION_CHANGES = {
36
36
  1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
37
- 2: '>= 1.0.0-rc.3'
37
+ 2: '== 1.0.0-rc.3',
38
+ 3: '== 1.0.0-rc.4',
39
+ 4: '>= 1.0.0'
38
40
  };
39
41
 
40
42
  Handlebars.helpers = {};
41
43
  Handlebars.partials = {};
42
44
 
45
+ var toString = Object.prototype.toString,
46
+ functionType = '[object Function]',
47
+ objectType = '[object Object]';
48
+
43
49
  Handlebars.registerHelper = function(name, fn, inverse) {
44
- if(inverse) { fn.not = inverse; }
45
- this.helpers[name] = fn;
50
+ if (toString.call(name) === objectType) {
51
+ if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); }
52
+ Handlebars.Utils.extend(this.helpers, name);
53
+ } else {
54
+ if (inverse) { fn.not = inverse; }
55
+ this.helpers[name] = fn;
56
+ }
46
57
  };
47
58
 
48
59
  Handlebars.registerPartial = function(name, str) {
49
- this.partials[name] = str;
60
+ if (toString.call(name) === objectType) {
61
+ Handlebars.Utils.extend(this.partials, name);
62
+ } else {
63
+ this.partials[name] = str;
64
+ }
50
65
  };
51
66
 
52
67
  Handlebars.registerHelper('helperMissing', function(arg) {
53
68
  if(arguments.length === 2) {
54
69
  return undefined;
55
70
  } else {
56
- throw new Error("Could not find property '" + arg + "'");
71
+ throw new Error("Missing helper: '" + arg + "'");
57
72
  }
58
73
  });
59
74
 
60
- var toString = Object.prototype.toString, functionType = "[object Function]";
61
-
62
75
  Handlebars.registerHelper('blockHelperMissing', function(context, options) {
63
76
  var inverse = options.inverse || function() {}, fn = options.fn;
64
77
 
@@ -112,6 +125,9 @@ Handlebars.registerHelper('each', function(context, options) {
112
125
  var fn = options.fn, inverse = options.inverse;
113
126
  var i = 0, ret = "", data;
114
127
 
128
+ var type = toString.call(context);
129
+ if(type === functionType) { context = context.call(this); }
130
+
115
131
  if (options.data) {
116
132
  data = Handlebars.createFrame(options.data);
117
133
  }
@@ -140,23 +156,26 @@ Handlebars.registerHelper('each', function(context, options) {
140
156
  return ret;
141
157
  });
142
158
 
143
- Handlebars.registerHelper('if', function(context, options) {
144
- var type = toString.call(context);
145
- if(type === functionType) { context = context.call(this); }
159
+ Handlebars.registerHelper('if', function(conditional, options) {
160
+ var type = toString.call(conditional);
161
+ if(type === functionType) { conditional = conditional.call(this); }
146
162
 
147
- if(!context || Handlebars.Utils.isEmpty(context)) {
163
+ if(!conditional || Handlebars.Utils.isEmpty(conditional)) {
148
164
  return options.inverse(this);
149
165
  } else {
150
166
  return options.fn(this);
151
167
  }
152
168
  });
153
169
 
154
- Handlebars.registerHelper('unless', function(context, options) {
155
- return Handlebars.helpers['if'].call(this, context, {fn: options.inverse, inverse: options.fn});
170
+ Handlebars.registerHelper('unless', function(conditional, options) {
171
+ return Handlebars.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn});
156
172
  });
157
173
 
158
174
  Handlebars.registerHelper('with', function(context, options) {
159
- return options.fn(context);
175
+ var type = toString.call(context);
176
+ if(type === functionType) { context = context.call(this); }
177
+
178
+ if (!Handlebars.Utils.isEmpty(context)) return options.fn(context);
160
179
  });
161
180
 
162
181
  Handlebars.registerHelper('log', function(context, options) {
@@ -169,9 +188,9 @@ Handlebars.registerHelper('log', function(context, options) {
169
188
  var handlebars = (function(){
170
189
  var parser = {trace: function trace() { },
171
190
  yy: {},
172
- symbols_: {"error":2,"root":3,"program":4,"EOF":5,"simpleInverse":6,"statements":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"OPEN_PARTIAL":24,"partialName":25,"params":26,"hash":27,"DATA":28,"param":29,"STRING":30,"INTEGER":31,"BOOLEAN":32,"hashSegments":33,"hashSegment":34,"ID":35,"EQUALS":36,"PARTIAL_NAME":37,"pathSegments":38,"SEP":39,"$accept":0,"$end":1},
173
- terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"OPEN_PARTIAL",28:"DATA",30:"STRING",31:"INTEGER",32:"BOOLEAN",35:"ID",36:"EQUALS",37:"PARTIAL_NAME",39:"SEP"},
174
- productions_: [0,[3,2],[4,2],[4,3],[4,2],[4,1],[4,1],[4,0],[7,1],[7,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[6,2],[17,3],[17,2],[17,2],[17,1],[17,1],[26,2],[26,1],[29,1],[29,1],[29,1],[29,1],[29,1],[27,1],[33,2],[33,1],[34,3],[34,3],[34,3],[34,3],[34,3],[25,1],[21,1],[38,3],[38,1]],
191
+ symbols_: {"error":2,"root":3,"program":4,"EOF":5,"simpleInverse":6,"statements":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"CLOSE_UNESCAPED":24,"OPEN_PARTIAL":25,"partialName":26,"params":27,"hash":28,"dataName":29,"param":30,"STRING":31,"INTEGER":32,"BOOLEAN":33,"hashSegments":34,"hashSegment":35,"ID":36,"EQUALS":37,"DATA":38,"pathSegments":39,"SEP":40,"$accept":0,"$end":1},
192
+ terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"CLOSE_UNESCAPED",25:"OPEN_PARTIAL",31:"STRING",32:"INTEGER",33:"BOOLEAN",36:"ID",37:"EQUALS",38:"DATA",40:"SEP"},
193
+ productions_: [0,[3,2],[4,2],[4,3],[4,2],[4,1],[4,1],[4,0],[7,1],[7,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[6,2],[17,3],[17,2],[17,2],[17,1],[17,1],[27,2],[27,1],[30,1],[30,1],[30,1],[30,1],[30,1],[28,1],[34,2],[34,1],[35,3],[35,3],[35,3],[35,3],[35,3],[26,1],[26,1],[26,1],[29,2],[21,1],[39,3],[39,1]],
175
194
  performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
176
195
 
177
196
  var $0 = $$.length - 1;
@@ -212,7 +231,10 @@ case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
212
231
  break;
213
232
  case 18: this.$ = $$[$0-1];
214
233
  break;
215
- case 19: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
234
+ case 19:
235
+ // Parsing out the '&' escape token at this level saves ~500 bytes after min due to the removal of one parser node.
236
+ this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], $$[$0-2][2] === '&');
237
+
216
238
  break;
217
239
  case 20: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true);
218
240
  break;
@@ -230,7 +252,7 @@ case 26: this.$ = [[$$[$0-1]], $$[$0]];
230
252
  break;
231
253
  case 27: this.$ = [[$$[$0]], null];
232
254
  break;
233
- case 28: this.$ = [[new yy.DataNode($$[$0])], null];
255
+ case 28: this.$ = [[$$[$0]], null];
234
256
  break;
235
257
  case 29: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
236
258
  break;
@@ -244,7 +266,7 @@ case 33: this.$ = new yy.IntegerNode($$[$0]);
244
266
  break;
245
267
  case 34: this.$ = new yy.BooleanNode($$[$0]);
246
268
  break;
247
- case 35: this.$ = new yy.DataNode($$[$0]);
269
+ case 35: this.$ = $$[$0];
248
270
  break;
249
271
  case 36: this.$ = new yy.HashNode($$[$0]);
250
272
  break;
@@ -260,20 +282,26 @@ case 41: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])];
260
282
  break;
261
283
  case 42: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])];
262
284
  break;
263
- case 43: this.$ = [$$[$0-2], new yy.DataNode($$[$0])];
285
+ case 43: this.$ = [$$[$0-2], $$[$0]];
264
286
  break;
265
287
  case 44: this.$ = new yy.PartialNameNode($$[$0]);
266
288
  break;
267
- case 45: this.$ = new yy.IdNode($$[$0]);
289
+ case 45: this.$ = new yy.PartialNameNode(new yy.StringNode($$[$0]));
290
+ break;
291
+ case 46: this.$ = new yy.PartialNameNode(new yy.IntegerNode($$[$0]));
292
+ break;
293
+ case 47: this.$ = new yy.DataNode($$[$0]);
268
294
  break;
269
- case 46: $$[$0-2].push($$[$0]); this.$ = $$[$0-2];
295
+ case 48: this.$ = new yy.IdNode($$[$0]);
270
296
  break;
271
- case 47: this.$ = [$$[$0]];
297
+ case 49: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2];
298
+ break;
299
+ case 50: this.$ = [{part: $$[$0]}];
272
300
  break;
273
301
  }
274
302
  },
275
- table: [{3:1,4:2,5:[2,7],6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],22:[1,14],23:[1,15],24:[1,16]},{1:[3]},{5:[1,17]},{5:[2,6],7:18,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,6],22:[1,14],23:[1,15],24:[1,16]},{5:[2,5],6:20,8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,5],22:[1,14],23:[1,15],24:[1,16]},{17:23,18:[1,22],21:24,28:[1,25],35:[1,27],38:26},{5:[2,8],14:[2,8],15:[2,8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],24:[2,8]},{4:28,6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,7],22:[1,14],23:[1,15],24:[1,16]},{4:29,6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,7],22:[1,14],23:[1,15],24:[1,16]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],24:[2,12]},{5:[2,13],14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],24:[2,13]},{5:[2,14],14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],24:[2,14]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],24:[2,15]},{17:30,21:24,28:[1,25],35:[1,27],38:26},{17:31,21:24,28:[1,25],35:[1,27],38:26},{17:32,21:24,28:[1,25],35:[1,27],38:26},{25:33,37:[1,34]},{1:[2,1]},{5:[2,2],8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,2],22:[1,14],23:[1,15],24:[1,16]},{17:23,21:24,28:[1,25],35:[1,27],38:26},{5:[2,4],7:35,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,4],22:[1,14],23:[1,15],24:[1,16]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],24:[2,9]},{5:[2,23],14:[2,23],15:[2,23],16:[2,23],19:[2,23],20:[2,23],22:[2,23],23:[2,23],24:[2,23]},{18:[1,36]},{18:[2,27],21:41,26:37,27:38,28:[1,45],29:39,30:[1,42],31:[1,43],32:[1,44],33:40,34:46,35:[1,47],38:26},{18:[2,28]},{18:[2,45],28:[2,45],30:[2,45],31:[2,45],32:[2,45],35:[2,45],39:[1,48]},{18:[2,47],28:[2,47],30:[2,47],31:[2,47],32:[2,47],35:[2,47],39:[2,47]},{10:49,20:[1,50]},{10:51,20:[1,50]},{18:[1,52]},{18:[1,53]},{18:[1,54]},{18:[1,55],21:56,35:[1,27],38:26},{18:[2,44],35:[2,44]},{5:[2,3],8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,3],22:[1,14],23:[1,15],24:[1,16]},{14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],24:[2,17]},{18:[2,25],21:41,27:57,28:[1,45],29:58,30:[1,42],31:[1,43],32:[1,44],33:40,34:46,35:[1,47],38:26},{18:[2,26]},{18:[2,30],28:[2,30],30:[2,30],31:[2,30],32:[2,30],35:[2,30]},{18:[2,36],34:59,35:[1,60]},{18:[2,31],28:[2,31],30:[2,31],31:[2,31],32:[2,31],35:[2,31]},{18:[2,32],28:[2,32],30:[2,32],31:[2,32],32:[2,32],35:[2,32]},{18:[2,33],28:[2,33],30:[2,33],31:[2,33],32:[2,33],35:[2,33]},{18:[2,34],28:[2,34],30:[2,34],31:[2,34],32:[2,34],35:[2,34]},{18:[2,35],28:[2,35],30:[2,35],31:[2,35],32:[2,35],35:[2,35]},{18:[2,38],35:[2,38]},{18:[2,47],28:[2,47],30:[2,47],31:[2,47],32:[2,47],35:[2,47],36:[1,61],39:[2,47]},{35:[1,62]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],24:[2,10]},{21:63,35:[1,27],38:26},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],24:[2,11]},{14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],24:[2,16]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],24:[2,19]},{5:[2,20],14:[2,20],15:[2,20],16:[2,20],19:[2,20],20:[2,20],22:[2,20],23:[2,20],24:[2,20]},{5:[2,21],14:[2,21],15:[2,21],16:[2,21],19:[2,21],20:[2,21],22:[2,21],23:[2,21],24:[2,21]},{18:[1,64]},{18:[2,24]},{18:[2,29],28:[2,29],30:[2,29],31:[2,29],32:[2,29],35:[2,29]},{18:[2,37],35:[2,37]},{36:[1,61]},{21:65,28:[1,69],30:[1,66],31:[1,67],32:[1,68],35:[1,27],38:26},{18:[2,46],28:[2,46],30:[2,46],31:[2,46],32:[2,46],35:[2,46],39:[2,46]},{18:[1,70]},{5:[2,22],14:[2,22],15:[2,22],16:[2,22],19:[2,22],20:[2,22],22:[2,22],23:[2,22],24:[2,22]},{18:[2,39],35:[2,39]},{18:[2,40],35:[2,40]},{18:[2,41],35:[2,41]},{18:[2,42],35:[2,42]},{18:[2,43],35:[2,43]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],24:[2,18]}],
276
- defaultActions: {17:[2,1],25:[2,28],38:[2,26],57:[2,24]},
303
+ table: [{3:1,4:2,5:[2,7],6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],22:[1,14],23:[1,15],25:[1,16]},{1:[3]},{5:[1,17]},{5:[2,6],7:18,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,6],22:[1,14],23:[1,15],25:[1,16]},{5:[2,5],6:20,8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,5],22:[1,14],23:[1,15],25:[1,16]},{17:23,18:[1,22],21:24,29:25,36:[1,28],38:[1,27],39:26},{5:[2,8],14:[2,8],15:[2,8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],25:[2,8]},{4:29,6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,7],22:[1,14],23:[1,15],25:[1,16]},{4:30,6:3,7:4,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,5],20:[2,7],22:[1,14],23:[1,15],25:[1,16]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],25:[2,12]},{5:[2,13],14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],25:[2,13]},{5:[2,14],14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],25:[2,14]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],25:[2,15]},{17:31,21:24,29:25,36:[1,28],38:[1,27],39:26},{17:32,21:24,29:25,36:[1,28],38:[1,27],39:26},{17:33,21:24,29:25,36:[1,28],38:[1,27],39:26},{21:35,26:34,31:[1,36],32:[1,37],36:[1,28],39:26},{1:[2,1]},{5:[2,2],8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,2],22:[1,14],23:[1,15],25:[1,16]},{17:23,21:24,29:25,36:[1,28],38:[1,27],39:26},{5:[2,4],7:38,8:6,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,4],22:[1,14],23:[1,15],25:[1,16]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],25:[2,9]},{5:[2,23],14:[2,23],15:[2,23],16:[2,23],19:[2,23],20:[2,23],22:[2,23],23:[2,23],25:[2,23]},{18:[1,39]},{18:[2,27],21:44,24:[2,27],27:40,28:41,29:48,30:42,31:[1,45],32:[1,46],33:[1,47],34:43,35:49,36:[1,50],38:[1,27],39:26},{18:[2,28],24:[2,28]},{18:[2,48],24:[2,48],31:[2,48],32:[2,48],33:[2,48],36:[2,48],38:[2,48],40:[1,51]},{21:52,36:[1,28],39:26},{18:[2,50],24:[2,50],31:[2,50],32:[2,50],33:[2,50],36:[2,50],38:[2,50],40:[2,50]},{10:53,20:[1,54]},{10:55,20:[1,54]},{18:[1,56]},{18:[1,57]},{24:[1,58]},{18:[1,59],21:60,36:[1,28],39:26},{18:[2,44],36:[2,44]},{18:[2,45],36:[2,45]},{18:[2,46],36:[2,46]},{5:[2,3],8:21,9:7,11:8,12:9,13:10,14:[1,11],15:[1,12],16:[1,13],19:[1,19],20:[2,3],22:[1,14],23:[1,15],25:[1,16]},{14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],25:[2,17]},{18:[2,25],21:44,24:[2,25],28:61,29:48,30:62,31:[1,45],32:[1,46],33:[1,47],34:43,35:49,36:[1,50],38:[1,27],39:26},{18:[2,26],24:[2,26]},{18:[2,30],24:[2,30],31:[2,30],32:[2,30],33:[2,30],36:[2,30],38:[2,30]},{18:[2,36],24:[2,36],35:63,36:[1,64]},{18:[2,31],24:[2,31],31:[2,31],32:[2,31],33:[2,31],36:[2,31],38:[2,31]},{18:[2,32],24:[2,32],31:[2,32],32:[2,32],33:[2,32],36:[2,32],38:[2,32]},{18:[2,33],24:[2,33],31:[2,33],32:[2,33],33:[2,33],36:[2,33],38:[2,33]},{18:[2,34],24:[2,34],31:[2,34],32:[2,34],33:[2,34],36:[2,34],38:[2,34]},{18:[2,35],24:[2,35],31:[2,35],32:[2,35],33:[2,35],36:[2,35],38:[2,35]},{18:[2,38],24:[2,38],36:[2,38]},{18:[2,50],24:[2,50],31:[2,50],32:[2,50],33:[2,50],36:[2,50],37:[1,65],38:[2,50],40:[2,50]},{36:[1,66]},{18:[2,47],24:[2,47],31:[2,47],32:[2,47],33:[2,47],36:[2,47],38:[2,47]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],25:[2,10]},{21:67,36:[1,28],39:26},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],25:[2,11]},{14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],25:[2,16]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],25:[2,19]},{5:[2,20],14:[2,20],15:[2,20],16:[2,20],19:[2,20],20:[2,20],22:[2,20],23:[2,20],25:[2,20]},{5:[2,21],14:[2,21],15:[2,21],16:[2,21],19:[2,21],20:[2,21],22:[2,21],23:[2,21],25:[2,21]},{18:[1,68]},{18:[2,24],24:[2,24]},{18:[2,29],24:[2,29],31:[2,29],32:[2,29],33:[2,29],36:[2,29],38:[2,29]},{18:[2,37],24:[2,37],36:[2,37]},{37:[1,65]},{21:69,29:73,31:[1,70],32:[1,71],33:[1,72],36:[1,28],38:[1,27],39:26},{18:[2,49],24:[2,49],31:[2,49],32:[2,49],33:[2,49],36:[2,49],38:[2,49],40:[2,49]},{18:[1,74]},{5:[2,22],14:[2,22],15:[2,22],16:[2,22],19:[2,22],20:[2,22],22:[2,22],23:[2,22],25:[2,22]},{18:[2,39],24:[2,39],36:[2,39]},{18:[2,40],24:[2,40],36:[2,40]},{18:[2,41],24:[2,41],36:[2,41]},{18:[2,42],24:[2,42],36:[2,42]},{18:[2,43],24:[2,43],36:[2,43]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],25:[2,18]}],
304
+ defaultActions: {17:[2,1]},
277
305
  parseError: function parseError(str, hash) {
278
306
  throw new Error(str);
279
307
  },
@@ -554,84 +582,82 @@ lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_STA
554
582
 
555
583
  var YYSTATE=YY_START
556
584
  switch($avoiding_name_collisions) {
557
- case 0:
585
+ case 0: yy_.yytext = "\\"; return 14;
586
+ break;
587
+ case 1:
558
588
  if(yy_.yytext.slice(-1) !== "\\") this.begin("mu");
559
589
  if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu");
560
590
  if(yy_.yytext) return 14;
561
591
 
562
592
  break;
563
- case 1: return 14;
593
+ case 2: return 14;
564
594
  break;
565
- case 2:
595
+ case 3:
566
596
  if(yy_.yytext.slice(-1) !== "\\") this.popState();
567
597
  if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1);
568
598
  return 14;
569
599
 
570
600
  break;
571
- case 3: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15;
601
+ case 4: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15;
572
602
  break;
573
- case 4: this.begin("par"); return 24;
603
+ case 5: return 25;
574
604
  break;
575
- case 5: return 16;
605
+ case 6: return 16;
576
606
  break;
577
- case 6: return 20;
578
- break;
579
- case 7: return 19;
607
+ case 7: return 20;
580
608
  break;
581
609
  case 8: return 19;
582
610
  break;
583
- case 9: return 23;
611
+ case 9: return 19;
584
612
  break;
585
613
  case 10: return 23;
586
614
  break;
587
- case 11: this.popState(); this.begin('com');
588
- break;
589
- case 12: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
615
+ case 11: return 22;
590
616
  break;
591
- case 13: return 22;
617
+ case 12: this.popState(); this.begin('com');
592
618
  break;
593
- case 14: return 36;
619
+ case 13: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
594
620
  break;
595
- case 15: return 35;
621
+ case 14: return 22;
596
622
  break;
597
- case 16: return 35;
623
+ case 15: return 37;
598
624
  break;
599
- case 17: return 39;
625
+ case 16: return 36;
600
626
  break;
601
- case 18: /*ignore whitespace*/
627
+ case 17: return 36;
602
628
  break;
603
- case 19: this.popState(); return 18;
629
+ case 18: return 40;
604
630
  break;
605
- case 20: this.popState(); return 18;
631
+ case 19: /*ignore whitespace*/
606
632
  break;
607
- case 21: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 30;
633
+ case 20: this.popState(); return 24;
608
634
  break;
609
- case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 30;
635
+ case 21: this.popState(); return 18;
610
636
  break;
611
- case 23: yy_.yytext = yy_.yytext.substr(1); return 28;
637
+ case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 31;
612
638
  break;
613
- case 24: return 32;
639
+ case 23: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 31;
614
640
  break;
615
- case 25: return 32;
641
+ case 24: return 38;
616
642
  break;
617
- case 26: return 31;
643
+ case 25: return 33;
618
644
  break;
619
- case 27: return 35;
645
+ case 26: return 33;
620
646
  break;
621
- case 28: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 35;
647
+ case 27: return 32;
622
648
  break;
623
- case 29: return 'INVALID';
649
+ case 28: return 36;
624
650
  break;
625
- case 30: /*ignore whitespace*/
651
+ case 29: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 36;
626
652
  break;
627
- case 31: this.popState(); return 37;
653
+ case 30: return 'INVALID';
628
654
  break;
629
- case 32: return 5;
655
+ case 31: return 5;
630
656
  break;
631
657
  }
632
658
  };
633
- lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[} ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@[a-zA-Z]+)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:-?[0-9]+(?=[}\s]))/,/^(?:[a-zA-Z0-9_$-]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:\s+)/,/^(?:[a-zA-Z0-9_$-/]+)/,/^(?:$)/];
634
- lexer.conditions = {"mu":{"rules":[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,32],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"com":{"rules":[3],"inclusive":false},"par":{"rules":[30,31],"inclusive":false},"INITIAL":{"rules":[0,1,32],"inclusive":true}};
659
+ lexer.rules = [/^(?:\\\\(?=(\{\{)))/,/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[}\/ ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:-?[0-9]+(?=[}\s]))/,/^(?:[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
660
+ lexer.conditions = {"mu":{"rules":[5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],"inclusive":false},"emu":{"rules":[3],"inclusive":false},"com":{"rules":[4],"inclusive":false},"INITIAL":{"rules":[0,1,2,31],"inclusive":true}};
635
661
  return lexer;})()
636
662
  parser.lexer = lexer;
637
663
  function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
@@ -688,13 +714,10 @@ Handlebars.AST.PartialNode = function(partialName, context) {
688
714
  };
689
715
 
690
716
  Handlebars.AST.BlockNode = function(mustache, program, inverse, close) {
691
- var verifyMatch = function(open, close) {
692
- if(open.original !== close.original) {
693
- throw new Handlebars.Exception(open.original + " doesn't match " + close.original);
694
- }
695
- };
717
+ if(mustache.id.original !== close.original) {
718
+ throw new Handlebars.Exception(mustache.id.original + " doesn't match " + close.original);
719
+ }
696
720
 
697
- verifyMatch(mustache.id, close);
698
721
  this.type = "block";
699
722
  this.mustache = mustache;
700
723
  this.program = program;
@@ -717,21 +740,24 @@ Handlebars.AST.HashNode = function(pairs) {
717
740
 
718
741
  Handlebars.AST.IdNode = function(parts) {
719
742
  this.type = "ID";
720
- this.original = parts.join(".");
721
743
 
722
- var dig = [], depth = 0;
744
+ var original = "",
745
+ dig = [],
746
+ depth = 0;
723
747
 
724
748
  for(var i=0,l=parts.length; i<l; i++) {
725
- var part = parts[i];
749
+ var part = parts[i].part;
750
+ original += (parts[i].separator || '') + part;
726
751
 
727
752
  if (part === ".." || part === "." || part === "this") {
728
- if (dig.length > 0) { throw new Handlebars.Exception("Invalid path: " + this.original); }
753
+ if (dig.length > 0) { throw new Handlebars.Exception("Invalid path: " + original); }
729
754
  else if (part === "..") { depth++; }
730
755
  else { this.isScoped = true; }
731
756
  }
732
757
  else { dig.push(part); }
733
758
  }
734
759
 
760
+ this.original = original;
735
761
  this.parts = dig;
736
762
  this.string = dig.join('.');
737
763
  this.depth = depth;
@@ -745,7 +771,7 @@ Handlebars.AST.IdNode = function(parts) {
745
771
 
746
772
  Handlebars.AST.PartialNameNode = function(name) {
747
773
  this.type = "PARTIAL_NAME";
748
- this.name = name;
774
+ this.name = name.original;
749
775
  };
750
776
 
751
777
  Handlebars.AST.DataNode = function(id) {
@@ -755,13 +781,15 @@ Handlebars.AST.DataNode = function(id) {
755
781
 
756
782
  Handlebars.AST.StringNode = function(string) {
757
783
  this.type = "STRING";
758
- this.string = string;
759
- this.stringModeValue = string;
784
+ this.original =
785
+ this.string =
786
+ this.stringModeValue = string;
760
787
  };
761
788
 
762
789
  Handlebars.AST.IntegerNode = function(integer) {
763
790
  this.type = "INTEGER";
764
- this.integer = integer;
791
+ this.original =
792
+ this.integer = integer;
765
793
  this.stringModeValue = Number(integer);
766
794
  };
767
795
 
@@ -815,6 +843,14 @@ var escapeChar = function(chr) {
815
843
  };
816
844
 
817
845
  Handlebars.Utils = {
846
+ extend: function(obj, value) {
847
+ for(var key in value) {
848
+ if(value.hasOwnProperty(key)) {
849
+ obj[key] = value[key];
850
+ }
851
+ }
852
+ },
853
+
818
854
  escapeExpression: function(string) {
819
855
  // don't escape SafeStrings, since they're already safe
820
856
  if (string instanceof Handlebars.SafeString) {
@@ -823,6 +859,11 @@ Handlebars.Utils = {
823
859
  return "";
824
860
  }
825
861
 
862
+ // Force a string conversion as this will be done by the append regardless and
863
+ // the regex test will do this transparently behind the scenes, causing issues if
864
+ // an object's to string has escaped characters in it.
865
+ string = string.toString();
866
+
826
867
  if(!possible.test(string)) { return string; }
827
868
  return string.replace(badChars, escapeChar);
828
869
  },
@@ -842,7 +883,6 @@ Handlebars.Utils = {
842
883
 
843
884
  /*jshint eqnull:true*/
844
885
  var Compiler = Handlebars.Compiler = function() {};
845
- var JavaScriptCompiler = Handlebars.JavaScriptCompiler = function() {};
846
886
 
847
887
  // the foundHelper register will disambiguate helper lookup from finding a
848
888
  // function in a context. This is necessary for mustache compatibility, which
@@ -1023,6 +1063,10 @@ Compiler.prototype = {
1023
1063
  val = pair[1];
1024
1064
 
1025
1065
  if (this.options.stringParams) {
1066
+ if(val.depth) {
1067
+ this.addDepth(val.depth);
1068
+ }
1069
+ this.opcode('getContext', val.depth || 0);
1026
1070
  this.opcode('pushStringParam', val.stringModeValue, val.type);
1027
1071
  } else {
1028
1072
  this.accept(val);
@@ -1106,7 +1150,7 @@ Compiler.prototype = {
1106
1150
 
1107
1151
  if (this.options.knownHelpers[name]) {
1108
1152
  this.opcode('invokeKnownHelper', params.length, name);
1109
- } else if (this.knownHelpersOnly) {
1153
+ } else if (this.options.knownHelpersOnly) {
1110
1154
  throw new Error("You specified knownHelpersOnly, but used the unknown helper " + name);
1111
1155
  } else {
1112
1156
  this.opcode('invokeHelper', params.length, name);
@@ -1131,7 +1175,15 @@ Compiler.prototype = {
1131
1175
 
1132
1176
  DATA: function(data) {
1133
1177
  this.options.data = true;
1134
- this.opcode('lookupData', data.id);
1178
+ if (data.id.isScoped || data.id.depth) {
1179
+ throw new Handlebars.Exception('Scoped data references are not supported: ' + data.original);
1180
+ }
1181
+
1182
+ this.opcode('lookupData');
1183
+ var parts = data.id.parts;
1184
+ for(var i=0, l=parts.length; i<l; i++) {
1185
+ this.opcode('lookup', parts[i]);
1186
+ }
1135
1187
  },
1136
1188
 
1137
1189
  STRING: function(string) {
@@ -1238,10 +1290,57 @@ Compiler.prototype = {
1238
1290
  }
1239
1291
  };
1240
1292
 
1293
+ Handlebars.precompile = function(input, options) {
1294
+ if (input == null || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode)) {
1295
+ throw new Handlebars.Exception("You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input);
1296
+ }
1297
+
1298
+ options = options || {};
1299
+ if (!('data' in options)) {
1300
+ options.data = true;
1301
+ }
1302
+ var ast = Handlebars.parse(input);
1303
+ var environment = new Compiler().compile(ast, options);
1304
+ return new Handlebars.JavaScriptCompiler().compile(environment, options);
1305
+ };
1306
+
1307
+ Handlebars.compile = function(input, options) {
1308
+ if (input == null || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode)) {
1309
+ throw new Handlebars.Exception("You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input);
1310
+ }
1311
+
1312
+ options = options || {};
1313
+ if (!('data' in options)) {
1314
+ options.data = true;
1315
+ }
1316
+ var compiled;
1317
+ function compile() {
1318
+ var ast = Handlebars.parse(input);
1319
+ var environment = new Compiler().compile(ast, options);
1320
+ var templateSpec = new Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
1321
+ return Handlebars.template(templateSpec);
1322
+ }
1323
+
1324
+ // Template is only compiled on first use and cached after that point.
1325
+ return function(context, options) {
1326
+ if (!compiled) {
1327
+ compiled = compile();
1328
+ }
1329
+ return compiled.call(this, context, options);
1330
+ };
1331
+ };
1332
+
1333
+ ;
1334
+ // lib/handlebars/compiler/javascript-compiler.js
1335
+ /*jshint eqnull:true*/
1336
+
1241
1337
  var Literal = function(value) {
1242
1338
  this.value = value;
1243
1339
  };
1244
1340
 
1341
+
1342
+ var JavaScriptCompiler = Handlebars.JavaScriptCompiler = function() {};
1343
+
1245
1344
  JavaScriptCompiler.prototype = {
1246
1345
  // PUBLIC API: You can override these methods in a subclass to provide
1247
1346
  // alternative compiled forms for name lookup and buffering semantics
@@ -1303,7 +1402,7 @@ JavaScriptCompiler.prototype = {
1303
1402
 
1304
1403
  this.i = 0;
1305
1404
 
1306
- for(l=opcodes.length; this.i<l; this.i++) {
1405
+ for(var l=opcodes.length; this.i<l; this.i++) {
1307
1406
  opcode = opcodes[this.i];
1308
1407
 
1309
1408
  if(opcode.opcode === 'DECLARE') {
@@ -1330,8 +1429,9 @@ JavaScriptCompiler.prototype = {
1330
1429
 
1331
1430
  if (!this.isChild) {
1332
1431
  var namespace = this.namespace;
1333
- var copies = "helpers = helpers || " + namespace + ".helpers;";
1334
- if (this.environment.usePartial) { copies = copies + " partials = partials || " + namespace + ".partials;"; }
1432
+
1433
+ var copies = "helpers = this.merge(helpers, " + namespace + ".helpers);";
1434
+ if (this.environment.usePartial) { copies = copies + " partials = this.merge(partials, " + namespace + ".partials);"; }
1335
1435
  if (this.options.data) { copies = copies + " data = data || {};"; }
1336
1436
  out.push(copies);
1337
1437
  } else {
@@ -1360,7 +1460,9 @@ JavaScriptCompiler.prototype = {
1360
1460
  // Generate minimizer alias mappings
1361
1461
  if (!this.isChild) {
1362
1462
  for (var alias in this.context.aliases) {
1363
- this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias];
1463
+ if (this.context.aliases.hasOwnProperty(alias)) {
1464
+ this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias];
1465
+ }
1364
1466
  }
1365
1467
  }
1366
1468
 
@@ -1579,7 +1681,7 @@ JavaScriptCompiler.prototype = {
1579
1681
  //
1580
1682
  // Push the result of looking up `id` on the current data
1581
1683
  lookupData: function(id) {
1582
- this.push(this.nameLookup('data', id, 'data'));
1684
+ this.push('data');
1583
1685
  },
1584
1686
 
1585
1687
  // [pushStringParam]
@@ -1607,16 +1709,18 @@ JavaScriptCompiler.prototype = {
1607
1709
 
1608
1710
  if (this.options.stringParams) {
1609
1711
  this.register('hashTypes', '{}');
1712
+ this.register('hashContexts', '{}');
1610
1713
  }
1611
1714
  },
1612
1715
  pushHash: function() {
1613
- this.hash = {values: [], types: []};
1716
+ this.hash = {values: [], types: [], contexts: []};
1614
1717
  },
1615
1718
  popHash: function() {
1616
1719
  var hash = this.hash;
1617
1720
  this.hash = undefined;
1618
1721
 
1619
1722
  if (this.options.stringParams) {
1723
+ this.register('hashContexts', '{' + hash.contexts.join(',') + '}');
1620
1724
  this.register('hashTypes', '{' + hash.types.join(',') + '}');
1621
1725
  }
1622
1726
  this.push('{\n ' + hash.values.join(',\n ') + '\n }');
@@ -1684,8 +1788,9 @@ JavaScriptCompiler.prototype = {
1684
1788
  this.context.aliases.helperMissing = 'helpers.helperMissing';
1685
1789
 
1686
1790
  var helper = this.lastHelper = this.setupHelper(paramSize, name, true);
1791
+ var nonHelper = this.nameLookup('depth' + this.lastContext, name, 'context');
1687
1792
 
1688
- this.push(helper.name);
1793
+ this.push(helper.name + ' || ' + nonHelper);
1689
1794
  this.replaceStack(function(name) {
1690
1795
  return name + ' ? ' + name + '.call(' +
1691
1796
  helper.callParams + ") " + ": helperMissing.call(" +
@@ -1759,14 +1864,18 @@ JavaScriptCompiler.prototype = {
1759
1864
  // and pushes the hash back onto the stack.
1760
1865
  assignToHash: function(key) {
1761
1866
  var value = this.popStack(),
1867
+ context,
1762
1868
  type;
1763
1869
 
1764
1870
  if (this.options.stringParams) {
1765
1871
  type = this.popStack();
1766
- this.popStack();
1872
+ context = this.popStack();
1767
1873
  }
1768
1874
 
1769
1875
  var hash = this.hash;
1876
+ if (context) {
1877
+ hash.contexts.push("'" + key + "': " + context);
1878
+ }
1770
1879
  if (type) {
1771
1880
  hash.types.push("'" + key + "': " + type);
1772
1881
  }
@@ -1827,12 +1936,7 @@ JavaScriptCompiler.prototype = {
1827
1936
  else { programParams.push("depth" + (depth - 1)); }
1828
1937
  }
1829
1938
 
1830
- if(depths.length === 0) {
1831
- return "self.program(" + programParams.join(", ") + ")";
1832
- } else {
1833
- programParams.shift();
1834
- return "self.programWithDepth(" + programParams.join(", ") + ")";
1835
- }
1939
+ return (depths.length === 0 ? "self.program(" : "self.programWithDepth(") + programParams.join(", ") + ")";
1836
1940
  },
1837
1941
 
1838
1942
  register: function(name, val) {
@@ -1964,7 +2068,9 @@ JavaScriptCompiler.prototype = {
1964
2068
  .replace(/\\/g, '\\\\')
1965
2069
  .replace(/"/g, '\\"')
1966
2070
  .replace(/\n/g, '\\n')
1967
- .replace(/\r/g, '\\r') + '"';
2071
+ .replace(/\r/g, '\\r')
2072
+ .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4
2073
+ .replace(/\u2029/g, '\\u2029') + '"';
1968
2074
  },
1969
2075
 
1970
2076
  setupHelper: function(paramSize, name, missingParams) {
@@ -2020,6 +2126,7 @@ JavaScriptCompiler.prototype = {
2020
2126
  if (this.options.stringParams) {
2021
2127
  options.push("contexts:[" + contexts.join(",") + "]");
2022
2128
  options.push("types:[" + types.join(",") + "]");
2129
+ options.push("hashContexts:hashContexts");
2023
2130
  options.push("hashTypes:hashTypes");
2024
2131
  }
2025
2132
 
@@ -2068,47 +2175,6 @@ JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
2068
2175
  }
2069
2176
  return false;
2070
2177
  };
2071
-
2072
- Handlebars.precompile = function(input, options) {
2073
- if (!input || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode)) {
2074
- throw new Handlebars.Exception("You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input);
2075
- }
2076
-
2077
- options = options || {};
2078
- if (!('data' in options)) {
2079
- options.data = true;
2080
- }
2081
- var ast = Handlebars.parse(input);
2082
- var environment = new Compiler().compile(ast, options);
2083
- return new JavaScriptCompiler().compile(environment, options);
2084
- };
2085
-
2086
- Handlebars.compile = function(input, options) {
2087
- if (!input || (typeof input !== 'string' && input.constructor !== Handlebars.AST.ProgramNode)) {
2088
- throw new Handlebars.Exception("You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input);
2089
- }
2090
-
2091
- options = options || {};
2092
- if (!('data' in options)) {
2093
- options.data = true;
2094
- }
2095
- var compiled;
2096
- function compile() {
2097
- var ast = Handlebars.parse(input);
2098
- var environment = new Compiler().compile(ast, options);
2099
- var templateSpec = new JavaScriptCompiler().compile(environment, options, undefined, true);
2100
- return Handlebars.template(templateSpec);
2101
- }
2102
-
2103
- // Template is only compiled on first use and cached after that point.
2104
- return function(context, options) {
2105
- if (!compiled) {
2106
- compiled = compile();
2107
- }
2108
- return compiled.call(this, context, options);
2109
- };
2110
- };
2111
-
2112
2178
  ;
2113
2179
  // lib/handlebars/runtime.js
2114
2180
 
@@ -2122,13 +2188,21 @@ Handlebars.VM = {
2122
2188
  program: function(i, fn, data) {
2123
2189
  var programWrapper = this.programs[i];
2124
2190
  if(data) {
2125
- return Handlebars.VM.program(fn, data);
2126
- } else if(programWrapper) {
2127
- return programWrapper;
2128
- } else {
2129
- programWrapper = this.programs[i] = Handlebars.VM.program(fn);
2130
- return programWrapper;
2191
+ programWrapper = Handlebars.VM.program(i, fn, data);
2192
+ } else if (!programWrapper) {
2193
+ programWrapper = this.programs[i] = Handlebars.VM.program(i, fn);
2194
+ }
2195
+ return programWrapper;
2196
+ },
2197
+ merge: function(param, common) {
2198
+ var ret = param || common;
2199
+
2200
+ if (param && common) {
2201
+ ret = {};
2202
+ Handlebars.Utils.extend(ret, common);
2203
+ Handlebars.Utils.extend(ret, param);
2131
2204
  }
2205
+ return ret;
2132
2206
  },
2133
2207
  programWithDepth: Handlebars.VM.programWithDepth,
2134
2208
  noop: Handlebars.VM.noop,
@@ -2160,21 +2234,27 @@ Handlebars.VM = {
2160
2234
  };
2161
2235
  },
2162
2236
 
2163
- programWithDepth: function(fn, data, $depth) {
2164
- var args = Array.prototype.slice.call(arguments, 2);
2237
+ programWithDepth: function(i, fn, data /*, $depth */) {
2238
+ var args = Array.prototype.slice.call(arguments, 3);
2165
2239
 
2166
- return function(context, options) {
2240
+ var program = function(context, options) {
2167
2241
  options = options || {};
2168
2242
 
2169
2243
  return fn.apply(this, [context, options.data || data].concat(args));
2170
2244
  };
2245
+ program.program = i;
2246
+ program.depth = args.length;
2247
+ return program;
2171
2248
  },
2172
- program: function(fn, data) {
2173
- return function(context, options) {
2249
+ program: function(i, fn, data) {
2250
+ var program = function(context, options) {
2174
2251
  options = options || {};
2175
2252
 
2176
2253
  return fn(context, options.data || data);
2177
2254
  };
2255
+ program.program = i;
2256
+ program.depth = 0;
2257
+ return program;
2178
2258
  },
2179
2259
  noop: function() { return ""; },
2180
2260
  invokePartial: function(partial, name, context, helpers, partials, data) {
@@ -2196,5 +2276,17 @@ Handlebars.VM = {
2196
2276
  Handlebars.template = Handlebars.VM.template;
2197
2277
  ;
2198
2278
  // lib/handlebars/browser-suffix.js
2199
- })(Handlebars);
2279
+ if (typeof module === 'object' && module.exports) {
2280
+ // CommonJS
2281
+ module.exports = Handlebars;
2282
+
2283
+ } else if (typeof define === "function" && define.amd) {
2284
+ // AMD modules
2285
+ define(function() { return Handlebars; });
2286
+
2287
+ } else {
2288
+ // other, i.e. browser
2289
+ this.Handlebars = Handlebars;
2290
+ }
2291
+ }).call(this);
2200
2292
  ;
@@ -20,45 +20,58 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  THE SOFTWARE.
22
22
 
23
+ @license
23
24
  */
24
25
 
25
26
  // lib/handlebars/browser-prefix.js
26
- var Handlebars = {};
27
-
28
- (function(Handlebars, undefined) {
27
+ (function(undefined) {
28
+ var Handlebars = {};
29
29
  ;
30
30
  // lib/handlebars/base.js
31
31
 
32
- Handlebars.VERSION = "1.0.0-rc.3";
33
- Handlebars.COMPILER_REVISION = 2;
32
+ Handlebars.VERSION = "1.0.0";
33
+ Handlebars.COMPILER_REVISION = 4;
34
34
 
35
35
  Handlebars.REVISION_CHANGES = {
36
36
  1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
37
- 2: '>= 1.0.0-rc.3'
37
+ 2: '== 1.0.0-rc.3',
38
+ 3: '== 1.0.0-rc.4',
39
+ 4: '>= 1.0.0'
38
40
  };
39
41
 
40
42
  Handlebars.helpers = {};
41
43
  Handlebars.partials = {};
42
44
 
45
+ var toString = Object.prototype.toString,
46
+ functionType = '[object Function]',
47
+ objectType = '[object Object]';
48
+
43
49
  Handlebars.registerHelper = function(name, fn, inverse) {
44
- if(inverse) { fn.not = inverse; }
45
- this.helpers[name] = fn;
50
+ if (toString.call(name) === objectType) {
51
+ if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); }
52
+ Handlebars.Utils.extend(this.helpers, name);
53
+ } else {
54
+ if (inverse) { fn.not = inverse; }
55
+ this.helpers[name] = fn;
56
+ }
46
57
  };
47
58
 
48
59
  Handlebars.registerPartial = function(name, str) {
49
- this.partials[name] = str;
60
+ if (toString.call(name) === objectType) {
61
+ Handlebars.Utils.extend(this.partials, name);
62
+ } else {
63
+ this.partials[name] = str;
64
+ }
50
65
  };
51
66
 
52
67
  Handlebars.registerHelper('helperMissing', function(arg) {
53
68
  if(arguments.length === 2) {
54
69
  return undefined;
55
70
  } else {
56
- throw new Error("Could not find property '" + arg + "'");
71
+ throw new Error("Missing helper: '" + arg + "'");
57
72
  }
58
73
  });
59
74
 
60
- var toString = Object.prototype.toString, functionType = "[object Function]";
61
-
62
75
  Handlebars.registerHelper('blockHelperMissing', function(context, options) {
63
76
  var inverse = options.inverse || function() {}, fn = options.fn;
64
77
 
@@ -112,6 +125,9 @@ Handlebars.registerHelper('each', function(context, options) {
112
125
  var fn = options.fn, inverse = options.inverse;
113
126
  var i = 0, ret = "", data;
114
127
 
128
+ var type = toString.call(context);
129
+ if(type === functionType) { context = context.call(this); }
130
+
115
131
  if (options.data) {
116
132
  data = Handlebars.createFrame(options.data);
117
133
  }
@@ -140,23 +156,26 @@ Handlebars.registerHelper('each', function(context, options) {
140
156
  return ret;
141
157
  });
142
158
 
143
- Handlebars.registerHelper('if', function(context, options) {
144
- var type = toString.call(context);
145
- if(type === functionType) { context = context.call(this); }
159
+ Handlebars.registerHelper('if', function(conditional, options) {
160
+ var type = toString.call(conditional);
161
+ if(type === functionType) { conditional = conditional.call(this); }
146
162
 
147
- if(!context || Handlebars.Utils.isEmpty(context)) {
163
+ if(!conditional || Handlebars.Utils.isEmpty(conditional)) {
148
164
  return options.inverse(this);
149
165
  } else {
150
166
  return options.fn(this);
151
167
  }
152
168
  });
153
169
 
154
- Handlebars.registerHelper('unless', function(context, options) {
155
- return Handlebars.helpers['if'].call(this, context, {fn: options.inverse, inverse: options.fn});
170
+ Handlebars.registerHelper('unless', function(conditional, options) {
171
+ return Handlebars.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn});
156
172
  });
157
173
 
158
174
  Handlebars.registerHelper('with', function(context, options) {
159
- return options.fn(context);
175
+ var type = toString.call(context);
176
+ if(type === functionType) { context = context.call(this); }
177
+
178
+ if (!Handlebars.Utils.isEmpty(context)) return options.fn(context);
160
179
  });
161
180
 
162
181
  Handlebars.registerHelper('log', function(context, options) {
@@ -203,6 +222,14 @@ var escapeChar = function(chr) {
203
222
  };
204
223
 
205
224
  Handlebars.Utils = {
225
+ extend: function(obj, value) {
226
+ for(var key in value) {
227
+ if(value.hasOwnProperty(key)) {
228
+ obj[key] = value[key];
229
+ }
230
+ }
231
+ },
232
+
206
233
  escapeExpression: function(string) {
207
234
  // don't escape SafeStrings, since they're already safe
208
235
  if (string instanceof Handlebars.SafeString) {
@@ -211,6 +238,11 @@ Handlebars.Utils = {
211
238
  return "";
212
239
  }
213
240
 
241
+ // Force a string conversion as this will be done by the append regardless and
242
+ // the regex test will do this transparently behind the scenes, causing issues if
243
+ // an object's to string has escaped characters in it.
244
+ string = string.toString();
245
+
214
246
  if(!possible.test(string)) { return string; }
215
247
  return string.replace(badChars, escapeChar);
216
248
  },
@@ -238,13 +270,21 @@ Handlebars.VM = {
238
270
  program: function(i, fn, data) {
239
271
  var programWrapper = this.programs[i];
240
272
  if(data) {
241
- return Handlebars.VM.program(fn, data);
242
- } else if(programWrapper) {
243
- return programWrapper;
244
- } else {
245
- programWrapper = this.programs[i] = Handlebars.VM.program(fn);
246
- return programWrapper;
273
+ programWrapper = Handlebars.VM.program(i, fn, data);
274
+ } else if (!programWrapper) {
275
+ programWrapper = this.programs[i] = Handlebars.VM.program(i, fn);
247
276
  }
277
+ return programWrapper;
278
+ },
279
+ merge: function(param, common) {
280
+ var ret = param || common;
281
+
282
+ if (param && common) {
283
+ ret = {};
284
+ Handlebars.Utils.extend(ret, common);
285
+ Handlebars.Utils.extend(ret, param);
286
+ }
287
+ return ret;
248
288
  },
249
289
  programWithDepth: Handlebars.VM.programWithDepth,
250
290
  noop: Handlebars.VM.noop,
@@ -276,21 +316,27 @@ Handlebars.VM = {
276
316
  };
277
317
  },
278
318
 
279
- programWithDepth: function(fn, data, $depth) {
280
- var args = Array.prototype.slice.call(arguments, 2);
319
+ programWithDepth: function(i, fn, data /*, $depth */) {
320
+ var args = Array.prototype.slice.call(arguments, 3);
281
321
 
282
- return function(context, options) {
322
+ var program = function(context, options) {
283
323
  options = options || {};
284
324
 
285
325
  return fn.apply(this, [context, options.data || data].concat(args));
286
326
  };
327
+ program.program = i;
328
+ program.depth = args.length;
329
+ return program;
287
330
  },
288
- program: function(fn, data) {
289
- return function(context, options) {
331
+ program: function(i, fn, data) {
332
+ var program = function(context, options) {
290
333
  options = options || {};
291
334
 
292
335
  return fn(context, options.data || data);
293
336
  };
337
+ program.program = i;
338
+ program.depth = 0;
339
+ return program;
294
340
  },
295
341
  noop: function() { return ""; },
296
342
  invokePartial: function(partial, name, context, helpers, partials, data) {
@@ -312,5 +358,17 @@ Handlebars.VM = {
312
358
  Handlebars.template = Handlebars.VM.template;
313
359
  ;
314
360
  // lib/handlebars/browser-suffix.js
315
- })(Handlebars);
361
+ if (typeof module === 'object' && module.exports) {
362
+ // CommonJS
363
+ module.exports = Handlebars;
364
+
365
+ } else if (typeof define === "function" && define.amd) {
366
+ // AMD modules
367
+ define(function() { return Handlebars; });
368
+
369
+ } else {
370
+ // other, i.e. browser
371
+ this.Handlebars = Handlebars;
372
+ }
373
+ }).call(this);
316
374
  ;
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handlebars-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
5
- prerelease:
4
+ version: 1.0.12
6
5
  platform: ruby
7
6
  authors:
8
7
  - Yehuda Katz
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-20 00:00:00.000000000 Z
11
+ date: 2013-06-26 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Handlebars.js source code wrapper for (pre)compilation gems.
15
14
  email:
@@ -23,27 +22,26 @@ files:
23
22
  - lib/handlebars/source.rb
24
23
  homepage: https://github.com/wycats/handlebars.js/
25
24
  licenses: []
25
+ metadata: {}
26
26
  post_install_message:
27
27
  rdoc_options: []
28
28
  require_paths:
29
29
  - lib
30
30
  required_ruby_version: !ruby/object:Gem::Requirement
31
- none: false
32
31
  requirements:
33
32
  - - ! '>='
34
33
  - !ruby/object:Gem::Version
35
34
  version: '0'
36
35
  required_rubygems_version: !ruby/object:Gem::Requirement
37
- none: false
38
36
  requirements:
39
37
  - - ! '>='
40
38
  - !ruby/object:Gem::Version
41
39
  version: '0'
42
40
  requirements: []
43
41
  rubyforge_project:
44
- rubygems_version: 1.8.24
42
+ rubygems_version: 2.0.3
45
43
  signing_key:
46
- specification_version: 3
44
+ specification_version: 4
47
45
  summary: Handlebars.js source code wrapper
48
46
  test_files: []
49
47
  has_rdoc: