handlebars-source 1.0.0 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (3) hide show
  1. data/dist/handlebars.js +226 -154
  2. data/dist/handlebars.runtime.js +48 -18
  3. metadata +1 -1
@@ -5,7 +5,7 @@ this.Handlebars = {};
5
5
 
6
6
  (function(Handlebars) {
7
7
 
8
- Handlebars.VERSION = "1.0.rc.1";
8
+ Handlebars.VERSION = "1.0.rc.2";
9
9
 
10
10
  Handlebars.helpers = {};
11
11
  Handlebars.partials = {};
@@ -62,22 +62,53 @@ Handlebars.createFrame = Object.create || function(object) {
62
62
  return obj;
63
63
  };
64
64
 
65
+ Handlebars.logger = {
66
+ DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
67
+
68
+ methodMap: {0: 'debug', 1: 'info', 2: 'warn', 3: 'error'},
69
+
70
+ // can be overridden in the host environment
71
+ log: function(level, obj) {
72
+ if (Handlebars.logger.level <= level) {
73
+ var method = Handlebars.logger.methodMap[level];
74
+ if (typeof console !== 'undefined' && console[method]) {
75
+ console[method].call(console, obj);
76
+ }
77
+ }
78
+ }
79
+ };
80
+
81
+ Handlebars.log = function(level, obj) { Handlebars.logger.log(level, obj); };
82
+
65
83
  Handlebars.registerHelper('each', function(context, options) {
66
84
  var fn = options.fn, inverse = options.inverse;
67
- var ret = "", data;
85
+ var i = 0, ret = "", data;
68
86
 
69
87
  if (options.data) {
70
88
  data = Handlebars.createFrame(options.data);
71
89
  }
72
90
 
73
- if(context && context.length > 0) {
74
- for(var i=0, j=context.length; i<j; i++) {
75
- if (data) { data.index = i; }
76
- ret = ret + fn(context[i], { data: data });
91
+ if(context && typeof context === 'object') {
92
+ if(context instanceof Array){
93
+ for(var j = context.length; i<j; i++) {
94
+ if (data) { data.index = i; }
95
+ ret = ret + fn(context[i], { data: data });
96
+ }
97
+ } else {
98
+ for(var key in context) {
99
+ if(context.hasOwnProperty(key)) {
100
+ if(data) { data.key = key; }
101
+ ret = ret + fn(context[key], {data: data});
102
+ i++;
103
+ }
104
+ }
77
105
  }
78
- } else {
106
+ }
107
+
108
+ if(i === 0){
79
109
  ret = inverse(this);
80
110
  }
111
+
81
112
  return ret;
82
113
  });
83
114
 
@@ -104,8 +135,9 @@ Handlebars.registerHelper('with', function(context, options) {
104
135
  return options.fn(context);
105
136
  });
106
137
 
107
- Handlebars.registerHelper('log', function(context) {
108
- Handlebars.log(context);
138
+ Handlebars.registerHelper('log', function(context, options) {
139
+ var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
140
+ Handlebars.log(level, context);
109
141
  });
110
142
 
111
143
  }(this.Handlebars));
@@ -115,103 +147,111 @@ Handlebars.registerHelper('log', function(context) {
115
147
  var handlebars = (function(){
116
148
  var parser = {trace: function trace() { },
117
149
  yy: {},
118
- symbols_: {"error":2,"root":3,"program":4,"EOF":5,"statements":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"OPEN_PARTIAL":24,"params":25,"hash":26,"DATA":27,"param":28,"STRING":29,"INTEGER":30,"BOOLEAN":31,"hashSegments":32,"hashSegment":33,"ID":34,"EQUALS":35,"pathSegments":36,"SEP":37,"$accept":0,"$end":1},
119
- 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",27:"DATA",29:"STRING",30:"INTEGER",31:"BOOLEAN",34:"ID",35:"EQUALS",37:"SEP"},
120
- productions_: [0,[3,2],[4,3],[4,1],[4,0],[6,1],[6,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],[7,2],[17,3],[17,2],[17,2],[17,1],[17,1],[25,2],[25,1],[28,1],[28,1],[28,1],[28,1],[28,1],[26,1],[32,2],[32,1],[33,3],[33,3],[33,3],[33,3],[33,3],[21,1],[36,3],[36,1]],
150
+ 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},
151
+ 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"},
152
+ 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]],
121
153
  performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
122
154
 
123
155
  var $0 = $$.length - 1;
124
156
  switch (yystate) {
125
157
  case 1: return $$[$0-1];
126
158
  break;
127
- case 2: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]);
159
+ case 2: this.$ = new yy.ProgramNode([], $$[$0]);
128
160
  break;
129
- case 3: this.$ = new yy.ProgramNode($$[$0]);
161
+ case 3: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]);
130
162
  break;
131
- case 4: this.$ = new yy.ProgramNode([]);
163
+ case 4: this.$ = new yy.ProgramNode($$[$0-1], []);
132
164
  break;
133
- case 5: this.$ = [$$[$0]];
165
+ case 5: this.$ = new yy.ProgramNode($$[$0]);
134
166
  break;
135
- case 6: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
167
+ case 6: this.$ = new yy.ProgramNode([], []);
136
168
  break;
137
- case 7: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0]);
169
+ case 7: this.$ = new yy.ProgramNode([]);
138
170
  break;
139
- case 8: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0]);
171
+ case 8: this.$ = [$$[$0]];
140
172
  break;
141
- case 9: this.$ = $$[$0];
173
+ case 9: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
142
174
  break;
143
- case 10: this.$ = $$[$0];
175
+ case 10: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0]);
144
176
  break;
145
- case 11: this.$ = new yy.ContentNode($$[$0]);
177
+ case 11: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0]);
146
178
  break;
147
- case 12: this.$ = new yy.CommentNode($$[$0]);
179
+ case 12: this.$ = $$[$0];
148
180
  break;
149
- case 13: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
181
+ case 13: this.$ = $$[$0];
150
182
  break;
151
- case 14: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
183
+ case 14: this.$ = new yy.ContentNode($$[$0]);
152
184
  break;
153
- case 15: this.$ = $$[$0-1];
185
+ case 15: this.$ = new yy.CommentNode($$[$0]);
154
186
  break;
155
187
  case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
156
188
  break;
157
- case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true);
189
+ case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
190
+ break;
191
+ case 18: this.$ = $$[$0-1];
192
+ break;
193
+ case 19: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
158
194
  break;
159
- case 18: this.$ = new yy.PartialNode($$[$0-1]);
195
+ case 20: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true);
160
196
  break;
161
- case 19: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]);
197
+ case 21: this.$ = new yy.PartialNode($$[$0-1]);
162
198
  break;
163
- case 20:
199
+ case 22: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]);
164
200
  break;
165
- case 21: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]];
201
+ case 23:
166
202
  break;
167
- case 22: this.$ = [[$$[$0-1]].concat($$[$0]), null];
203
+ case 24: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]];
168
204
  break;
169
- case 23: this.$ = [[$$[$0-1]], $$[$0]];
205
+ case 25: this.$ = [[$$[$0-1]].concat($$[$0]), null];
170
206
  break;
171
- case 24: this.$ = [[$$[$0]], null];
207
+ case 26: this.$ = [[$$[$0-1]], $$[$0]];
172
208
  break;
173
- case 25: this.$ = [[new yy.DataNode($$[$0])], null];
209
+ case 27: this.$ = [[$$[$0]], null];
174
210
  break;
175
- case 26: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
211
+ case 28: this.$ = [[new yy.DataNode($$[$0])], null];
176
212
  break;
177
- case 27: this.$ = [$$[$0]];
213
+ case 29: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
178
214
  break;
179
- case 28: this.$ = $$[$0];
215
+ case 30: this.$ = [$$[$0]];
180
216
  break;
181
- case 29: this.$ = new yy.StringNode($$[$0]);
217
+ case 31: this.$ = $$[$0];
182
218
  break;
183
- case 30: this.$ = new yy.IntegerNode($$[$0]);
219
+ case 32: this.$ = new yy.StringNode($$[$0]);
184
220
  break;
185
- case 31: this.$ = new yy.BooleanNode($$[$0]);
221
+ case 33: this.$ = new yy.IntegerNode($$[$0]);
186
222
  break;
187
- case 32: this.$ = new yy.DataNode($$[$0]);
223
+ case 34: this.$ = new yy.BooleanNode($$[$0]);
188
224
  break;
189
- case 33: this.$ = new yy.HashNode($$[$0]);
225
+ case 35: this.$ = new yy.DataNode($$[$0]);
190
226
  break;
191
- case 34: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
227
+ case 36: this.$ = new yy.HashNode($$[$0]);
192
228
  break;
193
- case 35: this.$ = [$$[$0]];
229
+ case 37: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
194
230
  break;
195
- case 36: this.$ = [$$[$0-2], $$[$0]];
231
+ case 38: this.$ = [$$[$0]];
196
232
  break;
197
- case 37: this.$ = [$$[$0-2], new yy.StringNode($$[$0])];
233
+ case 39: this.$ = [$$[$0-2], $$[$0]];
198
234
  break;
199
- case 38: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])];
235
+ case 40: this.$ = [$$[$0-2], new yy.StringNode($$[$0])];
200
236
  break;
201
- case 39: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])];
237
+ case 41: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])];
202
238
  break;
203
- case 40: this.$ = [$$[$0-2], new yy.DataNode($$[$0])];
239
+ case 42: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])];
204
240
  break;
205
- case 41: this.$ = new yy.IdNode($$[$0]);
241
+ case 43: this.$ = [$$[$0-2], new yy.DataNode($$[$0])];
206
242
  break;
207
- case 42: $$[$0-2].push($$[$0]); this.$ = $$[$0-2];
243
+ case 44: this.$ = new yy.PartialNameNode($$[$0]);
208
244
  break;
209
- case 43: this.$ = [$$[$0]];
245
+ case 45: this.$ = new yy.IdNode($$[$0]);
246
+ break;
247
+ case 46: $$[$0-2].push($$[$0]); this.$ = $$[$0-2];
248
+ break;
249
+ case 47: this.$ = [$$[$0]];
210
250
  break;
211
251
  }
212
252
  },
213
- table: [{3:1,4:2,5:[2,4],6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{1:[3]},{5:[1,16]},{5:[2,3],7:17,8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,19],20:[2,3],22:[1,13],23:[1,14],24:[1,15]},{5:[2,5],14:[2,5],15:[2,5],16:[2,5],19:[2,5],20:[2,5],22:[2,5],23:[2,5],24:[2,5]},{4:20,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{4:21,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{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,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]},{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]},{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]},{17:22,21:23,27:[1,24],34:[1,26],36:25},{17:27,21:23,27:[1,24],34:[1,26],36:25},{17:28,21:23,27:[1,24],34:[1,26],36:25},{17:29,21:23,27:[1,24],34:[1,26],36:25},{21:30,34:[1,26],36:25},{1:[2,1]},{6:31,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{5:[2,6],14:[2,6],15:[2,6],16:[2,6],19:[2,6],20:[2,6],22:[2,6],23:[2,6],24:[2,6]},{17:22,18:[1,32],21:23,27:[1,24],34:[1,26],36:25},{10:33,20:[1,34]},{10:35,20:[1,34]},{18:[1,36]},{18:[2,24],21:41,25:37,26:38,27:[1,45],28:39,29:[1,42],30:[1,43],31:[1,44],32:40,33:46,34:[1,47],36:25},{18:[2,25]},{18:[2,41],27:[2,41],29:[2,41],30:[2,41],31:[2,41],34:[2,41],37:[1,48]},{18:[2,43],27:[2,43],29:[2,43],30:[2,43],31:[2,43],34:[2,43],37:[2,43]},{18:[1,49]},{18:[1,50]},{18:[1,51]},{18:[1,52],21:53,34:[1,26],36:25},{5:[2,2],8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,2],22:[1,13],23:[1,14],24:[1,15]},{14:[2,20],15:[2,20],16:[2,20],19:[2,20],22:[2,20],23:[2,20],24:[2,20]},{5:[2,7],14:[2,7],15:[2,7],16:[2,7],19:[2,7],20:[2,7],22:[2,7],23:[2,7],24:[2,7]},{21:54,34:[1,26],36:25},{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]},{14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],24:[2,14]},{18:[2,22],21:41,26:55,27:[1,45],28:56,29:[1,42],30:[1,43],31:[1,44],32:40,33:46,34:[1,47],36:25},{18:[2,23]},{18:[2,27],27:[2,27],29:[2,27],30:[2,27],31:[2,27],34:[2,27]},{18:[2,33],33:57,34:[1,58]},{18:[2,28],27:[2,28],29:[2,28],30:[2,28],31:[2,28],34:[2,28]},{18:[2,29],27:[2,29],29:[2,29],30:[2,29],31:[2,29],34:[2,29]},{18:[2,30],27:[2,30],29:[2,30],30:[2,30],31:[2,30],34:[2,30]},{18:[2,31],27:[2,31],29:[2,31],30:[2,31],31:[2,31],34:[2,31]},{18:[2,32],27:[2,32],29:[2,32],30:[2,32],31:[2,32],34:[2,32]},{18:[2,35],34:[2,35]},{18:[2,43],27:[2,43],29:[2,43],30:[2,43],31:[2,43],34:[2,43],35:[1,59],37:[2,43]},{34:[1,60]},{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,16],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,17],14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],24:[2,17]},{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]},{18:[1,61]},{18:[1,62]},{18:[2,21]},{18:[2,26],27:[2,26],29:[2,26],30:[2,26],31:[2,26],34:[2,26]},{18:[2,34],34:[2,34]},{35:[1,59]},{21:63,27:[1,67],29:[1,64],30:[1,65],31:[1,66],34:[1,26],36:25},{18:[2,42],27:[2,42],29:[2,42],30:[2,42],31:[2,42],34:[2,42],37:[2,42]},{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,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]},{18:[2,36],34:[2,36]},{18:[2,37],34:[2,37]},{18:[2,38],34:[2,38]},{18:[2,39],34:[2,39]},{18:[2,40],34:[2,40]}],
214
- defaultActions: {16:[2,1],24:[2,25],38:[2,23],55:[2,21]},
253
+ 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]}],
254
+ defaultActions: {17:[2,1],25:[2,28],38:[2,26],57:[2,24]},
215
255
  parseError: function parseError(str, hash) {
216
256
  throw new Error(str);
217
257
  },
@@ -506,87 +546,75 @@ case 2:
506
546
  return 14;
507
547
 
508
548
  break;
509
- case 3: return 24;
549
+ case 3: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15;
510
550
  break;
511
- case 4: return 16;
551
+ case 4: this.begin("par"); return 24;
512
552
  break;
513
- case 5: return 20;
553
+ case 5: return 16;
514
554
  break;
515
- case 6: return 19;
555
+ case 6: return 20;
516
556
  break;
517
557
  case 7: return 19;
518
558
  break;
519
- case 8: return 23;
559
+ case 8: return 19;
520
560
  break;
521
561
  case 9: return 23;
522
562
  break;
523
- case 10: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
563
+ case 10: return 23;
564
+ break;
565
+ case 11: this.popState(); this.begin('com');
566
+ break;
567
+ case 12: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
568
+ break;
569
+ case 13: return 22;
524
570
  break;
525
- case 11: return 22;
571
+ case 14: return 36;
526
572
  break;
527
- case 12: return 35;
573
+ case 15: return 35;
528
574
  break;
529
- case 13: return 34;
575
+ case 16: return 35;
530
576
  break;
531
- case 14: return 34;
577
+ case 17: return 39;
532
578
  break;
533
- case 15: return 37;
579
+ case 18: /*ignore whitespace*/
534
580
  break;
535
- case 16: /*ignore whitespace*/
581
+ case 19: this.popState(); return 18;
536
582
  break;
537
- case 17: this.popState(); return 18;
583
+ case 20: this.popState(); return 18;
538
584
  break;
539
- case 18: this.popState(); return 18;
585
+ case 21: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 30;
540
586
  break;
541
- case 19: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 29;
587
+ case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 30;
542
588
  break;
543
- case 20: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 29;
589
+ case 23: yy_.yytext = yy_.yytext.substr(1); return 28;
544
590
  break;
545
- case 21: yy_.yytext = yy_.yytext.substr(1); return 27;
591
+ case 24: return 32;
546
592
  break;
547
- case 22: return 31;
593
+ case 25: return 32;
548
594
  break;
549
- case 23: return 31;
595
+ case 26: return 31;
550
596
  break;
551
- case 24: return 30;
597
+ case 27: return 35;
552
598
  break;
553
- case 25: return 34;
599
+ case 28: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 35;
554
600
  break;
555
- case 26: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 34;
601
+ case 29: return 'INVALID';
556
602
  break;
557
- case 27: return 'INVALID';
603
+ case 30: /*ignore whitespace*/
558
604
  break;
559
- case 28: return 5;
605
+ case 31: this.popState(); return 37;
606
+ break;
607
+ case 32: return 5;
560
608
  break;
561
609
  }
562
610
  };
563
- lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[} ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@[a-zA-Z]+)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:[0-9]+(?=[}\s]))/,/^(?:[a-zA-Z0-9_$-]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
564
- lexer.conditions = {"mu":{"rules":[3,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],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"INITIAL":{"rules":[0,1,28],"inclusive":true}};
611
+ 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_$-/]+)/,/^(?:$)/];
612
+ 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}};
565
613
  return lexer;})();
566
614
  parser.lexer = lexer;
567
615
  function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
568
616
  return new Parser;
569
- })();
570
- if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
571
- exports.parser = handlebars;
572
- exports.Parser = handlebars.Parser;
573
- exports.parse = function () { return handlebars.parse.apply(handlebars, arguments); };
574
- exports.main = function commonjsMain(args) {
575
- if (!args[1])
576
- throw new Error('Usage: '+args[0]+' FILE');
577
- var source, cwd;
578
- if (typeof process !== 'undefined') {
579
- source = require('fs').readFileSync(require('path').resolve(args[1]), "utf8");
580
- } else {
581
- source = require("file").path(require("file").cwd()).join(args[1]).read({charset: "utf-8"});
582
- }
583
- return exports.parser.parse(source);
584
- };
585
- if (typeof module !== 'undefined' && require.main === module) {
586
- exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
587
- }
588
- };
589
- ;
617
+ })();;
590
618
  // lib/handlebars/compiler/base.js
591
619
  Handlebars.Parser = handlebars;
592
620
 
@@ -597,17 +625,7 @@ Handlebars.parse = function(string) {
597
625
 
598
626
  Handlebars.print = function(ast) {
599
627
  return new Handlebars.PrintVisitor().accept(ast);
600
- };
601
-
602
- Handlebars.logger = {
603
- DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
604
-
605
- // override in the host environment
606
- log: function(level, str) {}
607
- };
608
-
609
- Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
610
- ;
628
+ };;
611
629
  // lib/handlebars/compiler/ast.js
612
630
  (function() {
613
631
 
@@ -641,13 +659,10 @@ Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
641
659
  // pass or at runtime.
642
660
  };
643
661
 
644
- Handlebars.AST.PartialNode = function(id, context) {
645
- this.type = "partial";
646
-
647
- // TODO: disallow complex IDs
648
-
649
- this.id = id;
650
- this.context = context;
662
+ Handlebars.AST.PartialNode = function(partialName, context) {
663
+ this.type = "partial";
664
+ this.partialName = partialName;
665
+ this.context = context;
651
666
  };
652
667
 
653
668
  var verifyMatch = function(open, close) {
@@ -699,6 +714,13 @@ Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
699
714
  // an ID is simple if it only has one part, and that part is not
700
715
  // `..` or `this`.
701
716
  this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;
717
+
718
+ this.stringModeValue = this.string;
719
+ };
720
+
721
+ Handlebars.AST.PartialNameNode = function(name) {
722
+ this.type = "PARTIAL_NAME";
723
+ this.name = name;
702
724
  };
703
725
 
704
726
  Handlebars.AST.DataNode = function(id) {
@@ -709,16 +731,19 @@ Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
709
731
  Handlebars.AST.StringNode = function(string) {
710
732
  this.type = "STRING";
711
733
  this.string = string;
734
+ this.stringModeValue = string;
712
735
  };
713
736
 
714
737
  Handlebars.AST.IntegerNode = function(integer) {
715
738
  this.type = "INTEGER";
716
739
  this.integer = integer;
740
+ this.stringModeValue = Number(integer);
717
741
  };
718
742
 
719
743
  Handlebars.AST.BooleanNode = function(bool) {
720
744
  this.type = "BOOLEAN";
721
745
  this.bool = bool;
746
+ this.stringModeValue = bool === "true";
722
747
  };
723
748
 
724
749
  Handlebars.AST.CommentNode = function(comment) {
@@ -728,14 +753,16 @@ Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
728
753
 
729
754
  })();;
730
755
  // lib/handlebars/utils.js
756
+
757
+ var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
758
+
731
759
  Handlebars.Exception = function(message) {
732
760
  var tmp = Error.prototype.constructor.apply(this, arguments);
733
761
 
734
- for (var p in tmp) {
735
- if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; }
762
+ // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
763
+ for (var idx = 0; idx < errorProps.length; idx++) {
764
+ this[errorProps[idx]] = tmp[errorProps[idx]];
736
765
  }
737
-
738
- this.message = tmp.message;
739
766
  };
740
767
  Handlebars.Exception.prototype = new Error();
741
768
 
@@ -778,11 +805,7 @@ Handlebars.SafeString.prototype.toString = function() {
778
805
  },
779
806
 
780
807
  isEmpty: function(value) {
781
- if (typeof value === "undefined") {
782
- return true;
783
- } else if (value === null) {
784
- return true;
785
- } else if (value === false) {
808
+ if (!value && value !== 0) {
786
809
  return true;
787
810
  } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
788
811
  return true;
@@ -921,7 +944,7 @@ Handlebars.JavaScriptCompiler = function() {};
921
944
  // evaluate it by executing `blockHelperMissing`
922
945
  this.opcode('pushProgram', program);
923
946
  this.opcode('pushProgram', inverse);
924
- this.opcode('pushLiteral', '{}');
947
+ this.opcode('pushHash');
925
948
  this.opcode('blockValue');
926
949
  } else {
927
950
  this.ambiguousMustache(mustache, program, inverse);
@@ -930,7 +953,7 @@ Handlebars.JavaScriptCompiler = function() {};
930
953
  // evaluate it by executing `blockHelperMissing`
931
954
  this.opcode('pushProgram', program);
932
955
  this.opcode('pushProgram', inverse);
933
- this.opcode('pushLiteral', '{}');
956
+ this.opcode('pushHash');
934
957
  this.opcode('ambiguousBlockValue');
935
958
  }
936
959
 
@@ -940,19 +963,24 @@ Handlebars.JavaScriptCompiler = function() {};
940
963
  hash: function(hash) {
941
964
  var pairs = hash.pairs, pair, val;
942
965
 
943
- this.opcode('push', '{}');
966
+ this.opcode('pushHash');
944
967
 
945
968
  for(var i=0, l=pairs.length; i<l; i++) {
946
969
  pair = pairs[i];
947
970
  val = pair[1];
948
971
 
949
- this.accept(val);
972
+ if (this.options.stringParams) {
973
+ this.opcode('pushStringParam', val.stringModeValue, val.type);
974
+ } else {
975
+ this.accept(val);
976
+ }
977
+
950
978
  this.opcode('assignToHash', pair[0]);
951
979
  }
952
980
  },
953
981
 
954
982
  partial: function(partial) {
955
- var id = partial.id;
983
+ var partialName = partial.partialName;
956
984
  this.usePartial = true;
957
985
 
958
986
  if(partial.context) {
@@ -961,7 +989,7 @@ Handlebars.JavaScriptCompiler = function() {};
961
989
  this.opcode('push', 'depth0');
962
990
  }
963
991
 
964
- this.opcode('invokePartial', id.original);
992
+ this.opcode('invokePartial', partialName.name);
965
993
  this.opcode('append');
966
994
  },
967
995
 
@@ -1116,7 +1144,7 @@ Handlebars.JavaScriptCompiler = function() {};
1116
1144
  }
1117
1145
 
1118
1146
  this.opcode('getContext', param.depth || 0);
1119
- this.opcode('pushStringParam', param.string);
1147
+ this.opcode('pushStringParam', param.stringModeValue, param.type);
1120
1148
  } else {
1121
1149
  this[param.type](param);
1122
1150
  }
@@ -1130,7 +1158,7 @@ Handlebars.JavaScriptCompiler = function() {};
1130
1158
  if(mustache.hash) {
1131
1159
  this.hash(mustache.hash);
1132
1160
  } else {
1133
- this.opcode('pushLiteral', '{}');
1161
+ this.opcode('pushHash');
1134
1162
  }
1135
1163
 
1136
1164
  return params;
@@ -1147,7 +1175,7 @@ Handlebars.JavaScriptCompiler = function() {};
1147
1175
  if(mustache.hash) {
1148
1176
  this.hash(mustache.hash);
1149
1177
  } else {
1150
- this.opcode('pushLiteral', '{}');
1178
+ this.opcode('pushHash');
1151
1179
  }
1152
1180
 
1153
1181
  return params;
@@ -1322,7 +1350,7 @@ Handlebars.JavaScriptCompiler = function() {};
1322
1350
 
1323
1351
  this.replaceStack(function(current) {
1324
1352
  params.splice(1, 0, current);
1325
- return current + " = blockHelperMissing.call(" + params.join(", ") + ")";
1353
+ return "blockHelperMissing.call(" + params.join(", ") + ")";
1326
1354
  });
1327
1355
  },
1328
1356
 
@@ -1434,7 +1462,7 @@ Handlebars.JavaScriptCompiler = function() {};
1434
1462
  this.context.aliases.functionType = '"function"';
1435
1463
 
1436
1464
  this.replaceStack(function(current) {
1437
- return "typeof " + current + " === functionType ? " + current + "() : " + current;
1465
+ return "typeof " + current + " === functionType ? " + current + ".apply(depth0) : " + current;
1438
1466
  });
1439
1467
  },
1440
1468
 
@@ -1469,9 +1497,24 @@ Handlebars.JavaScriptCompiler = function() {};
1469
1497
  // This opcode is designed for use in string mode, which
1470
1498
  // provides the string value of a parameter along with its
1471
1499
  // depth rather than resolving it immediately.
1472
- pushStringParam: function(string) {
1500
+ pushStringParam: function(string, type) {
1473
1501
  this.pushStackLiteral('depth' + this.lastContext);
1474
- this.pushString(string);
1502
+
1503
+ this.pushString(type);
1504
+
1505
+ if (typeof string === 'string') {
1506
+ this.pushString(string);
1507
+ } else {
1508
+ this.pushStackLiteral(string);
1509
+ }
1510
+ },
1511
+
1512
+ pushHash: function() {
1513
+ this.push('{}');
1514
+
1515
+ if (this.options.stringParams) {
1516
+ this.register('hashTypes', '{}');
1517
+ }
1475
1518
  },
1476
1519
 
1477
1520
  // [pushString]
@@ -1579,7 +1622,7 @@ Handlebars.JavaScriptCompiler = function() {};
1579
1622
  var nextStack = this.nextStack();
1580
1623
 
1581
1624
  this.source.push('if (foundHelper) { ' + nextStack + ' = foundHelper.call(' + helper.callParams + '); }');
1582
- this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '() : ' + nextStack + '; }');
1625
+ this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '.apply(depth0) : ' + nextStack + '; }');
1583
1626
  },
1584
1627
 
1585
1628
  // [invokePartial]
@@ -1597,7 +1640,7 @@ Handlebars.JavaScriptCompiler = function() {};
1597
1640
  }
1598
1641
 
1599
1642
  this.context.aliases.self = "this";
1600
- this.pushStack("self.invokePartial(" + params.join(", ") + ");");
1643
+ this.pushStack("self.invokePartial(" + params.join(", ") + ")");
1601
1644
  },
1602
1645
 
1603
1646
  // [assignToHash]
@@ -1609,6 +1652,13 @@ Handlebars.JavaScriptCompiler = function() {};
1609
1652
  // and pushes the hash back onto the stack.
1610
1653
  assignToHash: function(key) {
1611
1654
  var value = this.popStack();
1655
+
1656
+ if (this.options.stringParams) {
1657
+ var type = this.popStack();
1658
+ this.popStack();
1659
+ this.source.push("hashTypes['" + key + "'] = " + type + ";");
1660
+ }
1661
+
1612
1662
  var hash = this.topStack();
1613
1663
 
1614
1664
  this.source.push(hash + "['" + key + "'] = " + value + ";");
@@ -1678,21 +1728,28 @@ Handlebars.JavaScriptCompiler = function() {};
1678
1728
  },
1679
1729
 
1680
1730
  pushStack: function(item) {
1681
- this.source.push(this.incrStack() + " = " + item + ";");
1682
- this.compileStack.push("stack" + this.stackSlot);
1683
- return "stack" + this.stackSlot;
1731
+ var stack = this.incrStack();
1732
+ this.source.push(stack + " = " + item + ";");
1733
+ this.compileStack.push(stack);
1734
+ return stack;
1684
1735
  },
1685
1736
 
1686
1737
  replaceStack: function(callback) {
1687
- var item = callback.call(this, this.topStack());
1738
+ var stack = this.topStack(),
1739
+ item = callback.call(this, stack);
1688
1740
 
1689
- this.source.push(this.topStack() + " = " + item + ";");
1690
- return "stack" + this.stackSlot;
1741
+ // Prevent modification of the context depth variable. Through replaceStack
1742
+ if (/^depth/.test(stack)) {
1743
+ stack = this.nextStack();
1744
+ }
1745
+
1746
+ this.source.push(stack + " = " + item + ";");
1747
+ return stack;
1691
1748
  },
1692
1749
 
1693
1750
  nextStack: function(skipCompileStack) {
1694
1751
  var name = this.incrStack();
1695
- this.compileStack.push("stack" + this.stackSlot);
1752
+ this.compileStack.push(name);
1696
1753
  return name;
1697
1754
  },
1698
1755
 
@@ -1747,7 +1804,7 @@ Handlebars.JavaScriptCompiler = function() {};
1747
1804
  // the params and contexts arguments are passed in arrays
1748
1805
  // to fill in
1749
1806
  setupParams: function(paramSize, params) {
1750
- var options = [], contexts = [], param, inverse, program;
1807
+ var options = [], contexts = [], types = [], param, inverse, program;
1751
1808
 
1752
1809
  options.push("hash:" + this.popStack());
1753
1810
 
@@ -1776,12 +1833,15 @@ Handlebars.JavaScriptCompiler = function() {};
1776
1833
  params.push(param);
1777
1834
 
1778
1835
  if(this.options.stringParams) {
1836
+ types.push(this.popStack());
1779
1837
  contexts.push(this.popStack());
1780
1838
  }
1781
1839
  }
1782
1840
 
1783
1841
  if (this.options.stringParams) {
1784
1842
  options.push("contexts:[" + contexts.join(",") + "]");
1843
+ options.push("types:[" + types.join(",") + "]");
1844
+ options.push("hashTypes:hashTypes");
1785
1845
  }
1786
1846
 
1787
1847
  if(this.options.data) {
@@ -1827,16 +1887,28 @@ Handlebars.JavaScriptCompiler = function() {};
1827
1887
  })(Handlebars.Compiler, Handlebars.JavaScriptCompiler);
1828
1888
 
1829
1889
  Handlebars.precompile = function(string, options) {
1830
- options = options || {};
1890
+ if (typeof string !== 'string') {
1891
+ throw new Handlebars.Exception("You must pass a string to Handlebars.compile. You passed " + string);
1892
+ }
1831
1893
 
1894
+ options = options || {};
1895
+ if (!('data' in options)) {
1896
+ options.data = true;
1897
+ }
1832
1898
  var ast = Handlebars.parse(string);
1833
1899
  var environment = new Handlebars.Compiler().compile(ast, options);
1834
1900
  return new Handlebars.JavaScriptCompiler().compile(environment, options);
1835
1901
  };
1836
1902
 
1837
1903
  Handlebars.compile = function(string, options) {
1838
- options = options || {};
1904
+ if (typeof string !== 'string') {
1905
+ throw new Handlebars.Exception("You must pass a string to Handlebars.compile. You passed " + string);
1906
+ }
1839
1907
 
1908
+ options = options || {};
1909
+ if (!('data' in options)) {
1910
+ options.data = true;
1911
+ }
1840
1912
  var compiled;
1841
1913
  function compile() {
1842
1914
  var ast = Handlebars.parse(string);
@@ -5,7 +5,7 @@ this.Handlebars = {};
5
5
 
6
6
  (function(Handlebars) {
7
7
 
8
- Handlebars.VERSION = "1.0.rc.1";
8
+ Handlebars.VERSION = "1.0.rc.2";
9
9
 
10
10
  Handlebars.helpers = {};
11
11
  Handlebars.partials = {};
@@ -62,22 +62,53 @@ Handlebars.createFrame = Object.create || function(object) {
62
62
  return obj;
63
63
  };
64
64
 
65
+ Handlebars.logger = {
66
+ DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
67
+
68
+ methodMap: {0: 'debug', 1: 'info', 2: 'warn', 3: 'error'},
69
+
70
+ // can be overridden in the host environment
71
+ log: function(level, obj) {
72
+ if (Handlebars.logger.level <= level) {
73
+ var method = Handlebars.logger.methodMap[level];
74
+ if (typeof console !== 'undefined' && console[method]) {
75
+ console[method].call(console, obj);
76
+ }
77
+ }
78
+ }
79
+ };
80
+
81
+ Handlebars.log = function(level, obj) { Handlebars.logger.log(level, obj); };
82
+
65
83
  Handlebars.registerHelper('each', function(context, options) {
66
84
  var fn = options.fn, inverse = options.inverse;
67
- var ret = "", data;
85
+ var i = 0, ret = "", data;
68
86
 
69
87
  if (options.data) {
70
88
  data = Handlebars.createFrame(options.data);
71
89
  }
72
90
 
73
- if(context && context.length > 0) {
74
- for(var i=0, j=context.length; i<j; i++) {
75
- if (data) { data.index = i; }
76
- ret = ret + fn(context[i], { data: data });
91
+ if(context && typeof context === 'object') {
92
+ if(context instanceof Array){
93
+ for(var j = context.length; i<j; i++) {
94
+ if (data) { data.index = i; }
95
+ ret = ret + fn(context[i], { data: data });
96
+ }
97
+ } else {
98
+ for(var key in context) {
99
+ if(context.hasOwnProperty(key)) {
100
+ if(data) { data.key = key; }
101
+ ret = ret + fn(context[key], {data: data});
102
+ i++;
103
+ }
104
+ }
77
105
  }
78
- } else {
106
+ }
107
+
108
+ if(i === 0){
79
109
  ret = inverse(this);
80
110
  }
111
+
81
112
  return ret;
82
113
  });
83
114
 
@@ -104,21 +135,24 @@ Handlebars.registerHelper('with', function(context, options) {
104
135
  return options.fn(context);
105
136
  });
106
137
 
107
- Handlebars.registerHelper('log', function(context) {
108
- Handlebars.log(context);
138
+ Handlebars.registerHelper('log', function(context, options) {
139
+ var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
140
+ Handlebars.log(level, context);
109
141
  });
110
142
 
111
143
  }(this.Handlebars));
112
144
  ;
113
145
  // lib/handlebars/utils.js
146
+
147
+ var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
148
+
114
149
  Handlebars.Exception = function(message) {
115
150
  var tmp = Error.prototype.constructor.apply(this, arguments);
116
151
 
117
- for (var p in tmp) {
118
- if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; }
152
+ // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
153
+ for (var idx = 0; idx < errorProps.length; idx++) {
154
+ this[errorProps[idx]] = tmp[errorProps[idx]];
119
155
  }
120
-
121
- this.message = tmp.message;
122
156
  };
123
157
  Handlebars.Exception.prototype = new Error();
124
158
 
@@ -161,11 +195,7 @@ Handlebars.SafeString.prototype.toString = function() {
161
195
  },
162
196
 
163
197
  isEmpty: function(value) {
164
- if (typeof value === "undefined") {
165
- return true;
166
- } else if (value === null) {
167
- return true;
168
- } else if (value === false) {
198
+ if (!value && value !== 0) {
169
199
  return true;
170
200
  } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
171
201
  return true;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handlebars-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: