ember-rails-lite 0.8.0 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,9 +3,9 @@
3
3
  /*jshint eqnull:true*/
4
4
  this.Handlebars = {};
5
5
 
6
- (function() {
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 = {};
@@ -44,29 +44,71 @@ Handlebars.registerHelper('blockHelperMissing', function(context, options) {
44
44
  return inverse(this);
45
45
  } else if(type === "[object Array]") {
46
46
  if(context.length > 0) {
47
- for(var i=0, j=context.length; i<j; i++) {
48
- ret = ret + fn(context[i]);
49
- }
47
+ return Handlebars.helpers.each(context, options);
50
48
  } else {
51
- ret = inverse(this);
49
+ return inverse(this);
52
50
  }
53
- return ret;
54
51
  } else {
55
52
  return fn(context);
56
53
  }
57
54
  });
58
55
 
56
+ Handlebars.K = function() {};
57
+
58
+ Handlebars.createFrame = Object.create || function(object) {
59
+ Handlebars.K.prototype = object;
60
+ var obj = new Handlebars.K();
61
+ Handlebars.K.prototype = null;
62
+ return obj;
63
+ };
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
+
59
83
  Handlebars.registerHelper('each', function(context, options) {
60
84
  var fn = options.fn, inverse = options.inverse;
61
- var ret = "";
85
+ var i = 0, ret = "", data;
62
86
 
63
- if(context && context.length > 0) {
64
- for(var i=0, j=context.length; i<j; i++) {
65
- ret = ret + fn(context[i]);
87
+ if (options.data) {
88
+ data = Handlebars.createFrame(options.data);
89
+ }
90
+
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
+ }
66
105
  }
67
- } else {
106
+ }
107
+
108
+ if(i === 0){
68
109
  ret = inverse(this);
69
110
  }
111
+
70
112
  return ret;
71
113
  });
72
114
 
@@ -93,21 +135,24 @@ Handlebars.registerHelper('with', function(context, options) {
93
135
  return options.fn(context);
94
136
  });
95
137
 
96
- Handlebars.registerHelper('log', function(context) {
97
- 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);
98
141
  });
99
142
 
100
- }());
143
+ }(this.Handlebars));
101
144
  ;
102
145
  // lib/handlebars/utils.js
146
+
147
+ var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
148
+
103
149
  Handlebars.Exception = function(message) {
104
150
  var tmp = Error.prototype.constructor.apply(this, arguments);
105
151
 
106
- for (var p in tmp) {
107
- 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]];
108
155
  }
109
-
110
- this.message = tmp.message;
111
156
  };
112
157
  Handlebars.Exception.prototype = new Error();
113
158
 
@@ -121,6 +166,7 @@ Handlebars.SafeString.prototype.toString = function() {
121
166
 
122
167
  (function() {
123
168
  var escape = {
169
+ "&": "&amp;",
124
170
  "<": "&lt;",
125
171
  ">": "&gt;",
126
172
  '"': "&quot;",
@@ -128,7 +174,7 @@ Handlebars.SafeString.prototype.toString = function() {
128
174
  "`": "&#x60;"
129
175
  };
130
176
 
131
- var badChars = /&(?!\w+;)|[<>"'`]/g;
177
+ var badChars = /[&<>"'`]/g;
132
178
  var possible = /[&<>"'`]/;
133
179
 
134
180
  var escapeChar = function(chr) {
@@ -149,11 +195,7 @@ Handlebars.SafeString.prototype.toString = function() {
149
195
  },
150
196
 
151
197
  isEmpty: function(value) {
152
- if (typeof value === "undefined") {
153
- return true;
154
- } else if (value === null) {
155
- return true;
156
- } else if (value === false) {
198
+ if (!value && value !== 0) {
157
199
  return true;
158
200
  } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
159
201
  return true;
@@ -219,7 +261,7 @@ Handlebars.VM = {
219
261
  } else if (!Handlebars.compile) {
220
262
  throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
221
263
  } else {
222
- partials[name] = Handlebars.compile(partial);
264
+ partials[name] = Handlebars.compile(partial, {data: data !== undefined});
223
265
  return partials[name](context, options);
224
266
  }
225
267
  }
@@ -3,9 +3,9 @@
3
3
  /*jshint eqnull:true*/
4
4
  this.Handlebars = {};
5
5
 
6
- (function() {
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 = {};
@@ -44,29 +44,71 @@ Handlebars.registerHelper('blockHelperMissing', function(context, options) {
44
44
  return inverse(this);
45
45
  } else if(type === "[object Array]") {
46
46
  if(context.length > 0) {
47
- for(var i=0, j=context.length; i<j; i++) {
48
- ret = ret + fn(context[i]);
49
- }
47
+ return Handlebars.helpers.each(context, options);
50
48
  } else {
51
- ret = inverse(this);
49
+ return inverse(this);
52
50
  }
53
- return ret;
54
51
  } else {
55
52
  return fn(context);
56
53
  }
57
54
  });
58
55
 
56
+ Handlebars.K = function() {};
57
+
58
+ Handlebars.createFrame = Object.create || function(object) {
59
+ Handlebars.K.prototype = object;
60
+ var obj = new Handlebars.K();
61
+ Handlebars.K.prototype = null;
62
+ return obj;
63
+ };
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
+
59
83
  Handlebars.registerHelper('each', function(context, options) {
60
84
  var fn = options.fn, inverse = options.inverse;
61
- var ret = "";
85
+ var i = 0, ret = "", data;
62
86
 
63
- if(context && context.length > 0) {
64
- for(var i=0, j=context.length; i<j; i++) {
65
- ret = ret + fn(context[i]);
87
+ if (options.data) {
88
+ data = Handlebars.createFrame(options.data);
89
+ }
90
+
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
+ }
66
105
  }
67
- } else {
106
+ }
107
+
108
+ if(i === 0){
68
109
  ret = inverse(this);
69
110
  }
111
+
70
112
  return ret;
71
113
  });
72
114
 
@@ -93,302 +135,236 @@ Handlebars.registerHelper('with', function(context, options) {
93
135
  return options.fn(context);
94
136
  });
95
137
 
96
- Handlebars.registerHelper('log', function(context) {
97
- 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);
98
141
  });
99
142
 
100
- }());
143
+ }(this.Handlebars));
101
144
  ;
102
145
  // lib/handlebars/compiler/parser.js
103
146
  /* Jison generated parser */
104
147
  var handlebars = (function(){
105
-
106
148
  var parser = {trace: function trace() { },
107
149
  yy: {},
108
- 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,"param":27,"STRING":28,"INTEGER":29,"BOOLEAN":30,"hashSegments":31,"hashSegment":32,"ID":33,"EQUALS":34,"pathSegments":35,"SEP":36,"$accept":0,"$end":1},
109
- 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:"STRING",29:"INTEGER",30:"BOOLEAN",33:"ID",34:"EQUALS",36:"SEP"},
110
- 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],[25,2],[25,1],[27,1],[27,1],[27,1],[27,1],[26,1],[31,2],[31,1],[32,3],[32,3],[32,3],[32,3],[21,1],[35,3],[35,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]],
111
153
  performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
112
154
 
113
155
  var $0 = $$.length - 1;
114
156
  switch (yystate) {
115
157
  case 1: return $$[$0-1];
116
158
  break;
117
- case 2: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]);
159
+ case 2: this.$ = new yy.ProgramNode([], $$[$0]);
118
160
  break;
119
- case 3: this.$ = new yy.ProgramNode($$[$0]);
161
+ case 3: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]);
120
162
  break;
121
- case 4: this.$ = new yy.ProgramNode([]);
163
+ case 4: this.$ = new yy.ProgramNode($$[$0-1], []);
122
164
  break;
123
- case 5: this.$ = [$$[$0]];
165
+ case 5: this.$ = new yy.ProgramNode($$[$0]);
124
166
  break;
125
- case 6: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
167
+ case 6: this.$ = new yy.ProgramNode([], []);
126
168
  break;
127
- case 7: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0]);
169
+ case 7: this.$ = new yy.ProgramNode([]);
128
170
  break;
129
- case 8: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0]);
171
+ case 8: this.$ = [$$[$0]];
130
172
  break;
131
- case 9: this.$ = $$[$0];
173
+ case 9: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
132
174
  break;
133
- case 10: this.$ = $$[$0];
175
+ case 10: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0]);
134
176
  break;
135
- case 11: this.$ = new yy.ContentNode($$[$0]);
177
+ case 11: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0]);
136
178
  break;
137
- case 12: this.$ = new yy.CommentNode($$[$0]);
179
+ case 12: this.$ = $$[$0];
138
180
  break;
139
- case 13: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
181
+ case 13: this.$ = $$[$0];
140
182
  break;
141
- case 14: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
183
+ case 14: this.$ = new yy.ContentNode($$[$0]);
142
184
  break;
143
- case 15: this.$ = $$[$0-1];
185
+ case 15: this.$ = new yy.CommentNode($$[$0]);
144
186
  break;
145
187
  case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
146
188
  break;
147
- 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]);
194
+ break;
195
+ case 20: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true);
196
+ break;
197
+ case 21: this.$ = new yy.PartialNode($$[$0-1]);
148
198
  break;
149
- case 18: this.$ = new yy.PartialNode($$[$0-1]);
199
+ case 22: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]);
150
200
  break;
151
- case 19: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]);
201
+ case 23:
152
202
  break;
153
- case 20:
203
+ case 24: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]];
154
204
  break;
155
- case 21: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]];
205
+ case 25: this.$ = [[$$[$0-1]].concat($$[$0]), null];
156
206
  break;
157
- case 22: this.$ = [[$$[$0-1]].concat($$[$0]), null];
207
+ case 26: this.$ = [[$$[$0-1]], $$[$0]];
158
208
  break;
159
- case 23: this.$ = [[$$[$0-1]], $$[$0]];
209
+ case 27: this.$ = [[$$[$0]], null];
160
210
  break;
161
- case 24: this.$ = [[$$[$0]], null];
211
+ case 28: this.$ = [[new yy.DataNode($$[$0])], null];
162
212
  break;
163
- case 25: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
213
+ case 29: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
164
214
  break;
165
- case 26: this.$ = [$$[$0]];
215
+ case 30: this.$ = [$$[$0]];
166
216
  break;
167
- case 27: this.$ = $$[$0];
217
+ case 31: this.$ = $$[$0];
168
218
  break;
169
- case 28: this.$ = new yy.StringNode($$[$0]);
219
+ case 32: this.$ = new yy.StringNode($$[$0]);
170
220
  break;
171
- case 29: this.$ = new yy.IntegerNode($$[$0]);
221
+ case 33: this.$ = new yy.IntegerNode($$[$0]);
172
222
  break;
173
- case 30: this.$ = new yy.BooleanNode($$[$0]);
223
+ case 34: this.$ = new yy.BooleanNode($$[$0]);
174
224
  break;
175
- case 31: this.$ = new yy.HashNode($$[$0]);
225
+ case 35: this.$ = new yy.DataNode($$[$0]);
176
226
  break;
177
- case 32: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
227
+ case 36: this.$ = new yy.HashNode($$[$0]);
178
228
  break;
179
- case 33: this.$ = [$$[$0]];
229
+ case 37: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
180
230
  break;
181
- case 34: this.$ = [$$[$0-2], $$[$0]];
231
+ case 38: this.$ = [$$[$0]];
182
232
  break;
183
- case 35: this.$ = [$$[$0-2], new yy.StringNode($$[$0])];
233
+ case 39: this.$ = [$$[$0-2], $$[$0]];
184
234
  break;
185
- case 36: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])];
235
+ case 40: this.$ = [$$[$0-2], new yy.StringNode($$[$0])];
186
236
  break;
187
- case 37: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])];
237
+ case 41: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])];
188
238
  break;
189
- case 38: this.$ = new yy.IdNode($$[$0]);
239
+ case 42: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])];
190
240
  break;
191
- case 39: $$[$0-2].push($$[$0]); this.$ = $$[$0-2];
241
+ case 43: this.$ = [$$[$0-2], new yy.DataNode($$[$0])];
192
242
  break;
193
- case 40: this.$ = [$$[$0]];
243
+ case 44: this.$ = new yy.PartialNameNode($$[$0]);
244
+ break;
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]];
194
250
  break;
195
251
  }
196
252
  },
197
- 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,33:[1,25],35:24},{17:26,21:23,33:[1,25],35:24},{17:27,21:23,33:[1,25],35:24},{17:28,21:23,33:[1,25],35:24},{21:29,33:[1,25],35:24},{1:[2,1]},{6:30,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,31],21:23,33:[1,25],35:24},{10:32,20:[1,33]},{10:34,20:[1,33]},{18:[1,35]},{18:[2,24],21:40,25:36,26:37,27:38,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,38],28:[2,38],29:[2,38],30:[2,38],33:[2,38],36:[1,46]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],36:[2,40]},{18:[1,47]},{18:[1,48]},{18:[1,49]},{18:[1,50],21:51,33:[1,25],35:24},{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:52,33:[1,25],35:24},{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:40,26:53,27:54,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,23]},{18:[2,26],28:[2,26],29:[2,26],30:[2,26],33:[2,26]},{18:[2,31],32:55,33:[1,56]},{18:[2,27],28:[2,27],29:[2,27],30:[2,27],33:[2,27]},{18:[2,28],28:[2,28],29:[2,28],30:[2,28],33:[2,28]},{18:[2,29],28:[2,29],29:[2,29],30:[2,29],33:[2,29]},{18:[2,30],28:[2,30],29:[2,30],30:[2,30],33:[2,30]},{18:[2,33],33:[2,33]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],34:[1,57],36:[2,40]},{33:[1,58]},{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,59]},{18:[1,60]},{18:[2,21]},{18:[2,25],28:[2,25],29:[2,25],30:[2,25],33:[2,25]},{18:[2,32],33:[2,32]},{34:[1,57]},{21:61,28:[1,62],29:[1,63],30:[1,64],33:[1,25],35:24},{18:[2,39],28:[2,39],29:[2,39],30:[2,39],33:[2,39],36:[2,39]},{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,34],33:[2,34]},{18:[2,35],33:[2,35]},{18:[2,36],33:[2,36]},{18:[2,37],33:[2,37]}],
198
- defaultActions: {16:[2,1],37:[2,23],53:[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]},
199
255
  parseError: function parseError(str, hash) {
200
256
  throw new Error(str);
201
257
  },
202
258
  parse: function parse(input) {
203
- var self = this,
204
- stack = [0],
205
- vstack = [null], // semantic value stack
206
- lstack = [], // location stack
207
- table = this.table,
208
- yytext = '',
209
- yylineno = 0,
210
- yyleng = 0,
211
- recovering = 0,
212
- TERROR = 2,
213
- EOF = 1;
214
-
215
- //this.reductionCount = this.shiftCount = 0;
216
-
259
+ var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
217
260
  this.lexer.setInput(input);
218
261
  this.lexer.yy = this.yy;
219
262
  this.yy.lexer = this.lexer;
220
- if (typeof this.lexer.yylloc == 'undefined')
263
+ this.yy.parser = this;
264
+ if (typeof this.lexer.yylloc == "undefined")
221
265
  this.lexer.yylloc = {};
222
266
  var yyloc = this.lexer.yylloc;
223
267
  lstack.push(yyloc);
224
-
225
- if (typeof this.yy.parseError === 'function')
268
+ var ranges = this.lexer.options && this.lexer.options.ranges;
269
+ if (typeof this.yy.parseError === "function")
226
270
  this.parseError = this.yy.parseError;
227
-
228
- function popStack (n) {
229
- stack.length = stack.length - 2*n;
271
+ function popStack(n) {
272
+ stack.length = stack.length - 2 * n;
230
273
  vstack.length = vstack.length - n;
231
274
  lstack.length = lstack.length - n;
232
275
  }
233
-
234
276
  function lex() {
235
277
  var token;
236
- token = self.lexer.lex() || 1; // $end = 1
237
- // if token isn't its numeric value, convert
238
- if (typeof token !== 'number') {
278
+ token = self.lexer.lex() || 1;
279
+ if (typeof token !== "number") {
239
280
  token = self.symbols_[token] || token;
240
281
  }
241
282
  return token;
242
283
  }
243
-
244
- var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
284
+ var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
245
285
  while (true) {
246
- // retreive state number from top of stack
247
- state = stack[stack.length-1];
248
-
249
- // use default actions if available
286
+ state = stack[stack.length - 1];
250
287
  if (this.defaultActions[state]) {
251
288
  action = this.defaultActions[state];
252
289
  } else {
253
- if (symbol == null)
290
+ if (symbol === null || typeof symbol == "undefined") {
254
291
  symbol = lex();
255
- // read action for current state and first input
292
+ }
256
293
  action = table[state] && table[state][symbol];
257
294
  }
258
-
259
- // handle parse error
260
- _handle_error:
261
- if (typeof action === 'undefined' || !action.length || !action[0]) {
262
-
295
+ if (typeof action === "undefined" || !action.length || !action[0]) {
296
+ var errStr = "";
263
297
  if (!recovering) {
264
- // Report error
265
298
  expected = [];
266
- for (p in table[state]) if (this.terminals_[p] && p > 2) {
267
- expected.push("'"+this.terminals_[p]+"'");
268
- }
269
- var errStr = '';
299
+ for (p in table[state])
300
+ if (this.terminals_[p] && p > 2) {
301
+ expected.push("'" + this.terminals_[p] + "'");
302
+ }
270
303
  if (this.lexer.showPosition) {
271
- errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
304
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
272
305
  } else {
273
- errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
274
- (symbol == 1 /*EOF*/ ? "end of input" :
275
- ("'"+(this.terminals_[symbol] || symbol)+"'"));
306
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'");
276
307
  }
277
- this.parseError(errStr,
278
- {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
308
+ this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
279
309
  }
280
-
281
- // just recovered from another error
282
- if (recovering == 3) {
283
- if (symbol == EOF) {
284
- throw new Error(errStr || 'Parsing halted.');
285
- }
286
-
287
- // discard current lookahead and grab another
310
+ }
311
+ if (action[0] instanceof Array && action.length > 1) {
312
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
313
+ }
314
+ switch (action[0]) {
315
+ case 1:
316
+ stack.push(symbol);
317
+ vstack.push(this.lexer.yytext);
318
+ lstack.push(this.lexer.yylloc);
319
+ stack.push(action[1]);
320
+ symbol = null;
321
+ if (!preErrorSymbol) {
288
322
  yyleng = this.lexer.yyleng;
289
323
  yytext = this.lexer.yytext;
290
324
  yylineno = this.lexer.yylineno;
291
325
  yyloc = this.lexer.yylloc;
292
- symbol = lex();
326
+ if (recovering > 0)
327
+ recovering--;
328
+ } else {
329
+ symbol = preErrorSymbol;
330
+ preErrorSymbol = null;
293
331
  }
294
-
295
- // try to recover from error
296
- while (1) {
297
- // check for error recovery rule in this state
298
- if ((TERROR.toString()) in table[state]) {
299
- break;
300
- }
301
- if (state == 0) {
302
- throw new Error(errStr || 'Parsing halted.');
303
- }
304
- popStack(1);
305
- state = stack[stack.length-1];
332
+ break;
333
+ case 2:
334
+ len = this.productions_[action[1]][1];
335
+ yyval.$ = vstack[vstack.length - len];
336
+ yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column};
337
+ if (ranges) {
338
+ yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
306
339
  }
307
-
308
- preErrorSymbol = symbol; // save the lookahead token
309
- symbol = TERROR; // insert generic error symbol as new lookahead
310
- state = stack[stack.length-1];
311
- action = table[state] && table[state][TERROR];
312
- recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
313
- }
314
-
315
- // this shouldn't happen, unless resolve defaults are off
316
- if (action[0] instanceof Array && action.length > 1) {
317
- throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
318
- }
319
-
320
- switch (action[0]) {
321
-
322
- case 1: // shift
323
- //this.shiftCount++;
324
-
325
- stack.push(symbol);
326
- vstack.push(this.lexer.yytext);
327
- lstack.push(this.lexer.yylloc);
328
- stack.push(action[1]); // push state
329
- symbol = null;
330
- if (!preErrorSymbol) { // normal execution/no error
331
- yyleng = this.lexer.yyleng;
332
- yytext = this.lexer.yytext;
333
- yylineno = this.lexer.yylineno;
334
- yyloc = this.lexer.yylloc;
335
- if (recovering > 0)
336
- recovering--;
337
- } else { // error just occurred, resume old lookahead f/ before error
338
- symbol = preErrorSymbol;
339
- preErrorSymbol = null;
340
- }
341
- break;
342
-
343
- case 2: // reduce
344
- //this.reductionCount++;
345
-
346
- len = this.productions_[action[1]][1];
347
-
348
- // perform semantic action
349
- yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
350
- // default location, uses first token for firsts, last for lasts
351
- yyval._$ = {
352
- first_line: lstack[lstack.length-(len||1)].first_line,
353
- last_line: lstack[lstack.length-1].last_line,
354
- first_column: lstack[lstack.length-(len||1)].first_column,
355
- last_column: lstack[lstack.length-1].last_column
356
- };
357
- r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
358
-
359
- if (typeof r !== 'undefined') {
360
- return r;
361
- }
362
-
363
- // pop off stack
364
- if (len) {
365
- stack = stack.slice(0,-1*len*2);
366
- vstack = vstack.slice(0, -1*len);
367
- lstack = lstack.slice(0, -1*len);
368
- }
369
-
370
- stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
371
- vstack.push(yyval.$);
372
- lstack.push(yyval._$);
373
- // goto new state = table[STATE][NONTERMINAL]
374
- newState = table[stack[stack.length-2]][stack[stack.length-1]];
375
- stack.push(newState);
376
- break;
377
-
378
- case 3: // accept
379
- return true;
340
+ r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
341
+ if (typeof r !== "undefined") {
342
+ return r;
343
+ }
344
+ if (len) {
345
+ stack = stack.slice(0, -1 * len * 2);
346
+ vstack = vstack.slice(0, -1 * len);
347
+ lstack = lstack.slice(0, -1 * len);
348
+ }
349
+ stack.push(this.productions_[action[1]][0]);
350
+ vstack.push(yyval.$);
351
+ lstack.push(yyval._$);
352
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
353
+ stack.push(newState);
354
+ break;
355
+ case 3:
356
+ return true;
380
357
  }
381
-
382
358
  }
383
-
384
359
  return true;
385
- }};/* Jison generated lexer */
360
+ }
361
+ };
362
+ /* Jison generated lexer */
386
363
  var lexer = (function(){
387
-
388
364
  var lexer = ({EOF:1,
389
365
  parseError:function parseError(str, hash) {
390
- if (this.yy.parseError) {
391
- this.yy.parseError(str, hash);
366
+ if (this.yy.parser) {
367
+ this.yy.parser.parseError(str, hash);
392
368
  } else {
393
369
  throw new Error(str);
394
370
  }
@@ -400,27 +376,64 @@ setInput:function (input) {
400
376
  this.yytext = this.matched = this.match = '';
401
377
  this.conditionStack = ['INITIAL'];
402
378
  this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
379
+ if (this.options.ranges) this.yylloc.range = [0,0];
380
+ this.offset = 0;
403
381
  return this;
404
382
  },
405
383
  input:function () {
406
384
  var ch = this._input[0];
407
- this.yytext+=ch;
385
+ this.yytext += ch;
408
386
  this.yyleng++;
409
- this.match+=ch;
410
- this.matched+=ch;
411
- var lines = ch.match(/\n/);
412
- if (lines) this.yylineno++;
387
+ this.offset++;
388
+ this.match += ch;
389
+ this.matched += ch;
390
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
391
+ if (lines) {
392
+ this.yylineno++;
393
+ this.yylloc.last_line++;
394
+ } else {
395
+ this.yylloc.last_column++;
396
+ }
397
+ if (this.options.ranges) this.yylloc.range[1]++;
398
+
413
399
  this._input = this._input.slice(1);
414
400
  return ch;
415
401
  },
416
402
  unput:function (ch) {
403
+ var len = ch.length;
404
+ var lines = ch.split(/(?:\r\n?|\n)/g);
405
+
417
406
  this._input = ch + this._input;
407
+ this.yytext = this.yytext.substr(0, this.yytext.length-len-1);
408
+ //this.yyleng -= len;
409
+ this.offset -= len;
410
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
411
+ this.match = this.match.substr(0, this.match.length-1);
412
+ this.matched = this.matched.substr(0, this.matched.length-1);
413
+
414
+ if (lines.length-1) this.yylineno -= lines.length-1;
415
+ var r = this.yylloc.range;
416
+
417
+ this.yylloc = {first_line: this.yylloc.first_line,
418
+ last_line: this.yylineno+1,
419
+ first_column: this.yylloc.first_column,
420
+ last_column: lines ?
421
+ (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length:
422
+ this.yylloc.first_column - len
423
+ };
424
+
425
+ if (this.options.ranges) {
426
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
427
+ }
418
428
  return this;
419
429
  },
420
430
  more:function () {
421
431
  this._more = true;
422
432
  return this;
423
433
  },
434
+ less:function (n) {
435
+ this.unput(this.match.slice(n));
436
+ },
424
437
  pastInput:function () {
425
438
  var past = this.matched.substr(0, this.matched.length - this.match.length);
426
439
  return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
@@ -445,6 +458,8 @@ next:function () {
445
458
 
446
459
  var token,
447
460
  match,
461
+ tempMatch,
462
+ index,
448
463
  col,
449
464
  lines;
450
465
  if (!this._more) {
@@ -453,30 +468,39 @@ next:function () {
453
468
  }
454
469
  var rules = this._currentRules();
455
470
  for (var i=0;i < rules.length; i++) {
456
- match = this._input.match(this.rules[rules[i]]);
457
- if (match) {
458
- lines = match[0].match(/\n.*/g);
459
- if (lines) this.yylineno += lines.length;
460
- this.yylloc = {first_line: this.yylloc.last_line,
461
- last_line: this.yylineno+1,
462
- first_column: this.yylloc.last_column,
463
- last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}
464
- this.yytext += match[0];
465
- this.match += match[0];
466
- this.matches = match;
467
- this.yyleng = this.yytext.length;
468
- this._more = false;
469
- this._input = this._input.slice(match[0].length);
470
- this.matched += match[0];
471
- token = this.performAction.call(this, this.yy, this, rules[i],this.conditionStack[this.conditionStack.length-1]);
472
- if (token) return token;
473
- else return;
471
+ tempMatch = this._input.match(this.rules[rules[i]]);
472
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
473
+ match = tempMatch;
474
+ index = i;
475
+ if (!this.options.flex) break;
474
476
  }
475
477
  }
478
+ if (match) {
479
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
480
+ if (lines) this.yylineno += lines.length;
481
+ this.yylloc = {first_line: this.yylloc.last_line,
482
+ last_line: this.yylineno+1,
483
+ first_column: this.yylloc.last_column,
484
+ last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length};
485
+ this.yytext += match[0];
486
+ this.match += match[0];
487
+ this.matches = match;
488
+ this.yyleng = this.yytext.length;
489
+ if (this.options.ranges) {
490
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
491
+ }
492
+ this._more = false;
493
+ this._input = this._input.slice(match[0].length);
494
+ this.matched += match[0];
495
+ token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
496
+ if (this.done && this._input) this.done = false;
497
+ if (token) return token;
498
+ else return;
499
+ }
476
500
  if (this._input === "") {
477
501
  return this.EOF;
478
502
  } else {
479
- this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
503
+ return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
480
504
  {text: "", token: null, line: this.yylineno});
481
505
  }
482
506
  },
@@ -503,6 +527,7 @@ topState:function () {
503
527
  pushState:function begin(condition) {
504
528
  this.begin(condition);
505
529
  }});
530
+ lexer.options = {};
506
531
  lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
507
532
 
508
533
  var YYSTATE=YY_START
@@ -515,82 +540,81 @@ case 0:
515
540
  break;
516
541
  case 1: return 14;
517
542
  break;
518
- case 2: this.popState(); return 14;
543
+ case 2:
544
+ if(yy_.yytext.slice(-1) !== "\\") this.popState();
545
+ if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1);
546
+ return 14;
547
+
519
548
  break;
520
- case 3: return 24;
549
+ case 3: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15;
521
550
  break;
522
- case 4: return 16;
551
+ case 4: this.begin("par"); return 24;
523
552
  break;
524
- case 5: return 20;
553
+ case 5: return 16;
525
554
  break;
526
- case 6: return 19;
555
+ case 6: return 20;
527
556
  break;
528
557
  case 7: return 19;
529
558
  break;
530
- case 8: return 23;
559
+ case 8: return 19;
531
560
  break;
532
561
  case 9: return 23;
533
562
  break;
534
- 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;
535
570
  break;
536
- case 11: return 22;
571
+ case 14: return 36;
537
572
  break;
538
- case 12: return 34;
573
+ case 15: return 35;
539
574
  break;
540
- case 13: return 33;
575
+ case 16: return 35;
541
576
  break;
542
- case 14: return 33;
577
+ case 17: return 39;
543
578
  break;
544
- case 15: return 36;
579
+ case 18: /*ignore whitespace*/
545
580
  break;
546
- case 16: /*ignore whitespace*/
581
+ case 19: this.popState(); return 18;
547
582
  break;
548
- case 17: this.popState(); return 18;
583
+ case 20: this.popState(); return 18;
549
584
  break;
550
- case 18: this.popState(); return 18;
585
+ case 21: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 30;
551
586
  break;
552
- case 19: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 28;
587
+ case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 30;
553
588
  break;
554
- case 20: return 30;
589
+ case 23: yy_.yytext = yy_.yytext.substr(1); return 28;
555
590
  break;
556
- case 21: return 30;
591
+ case 24: return 32;
557
592
  break;
558
- case 22: return 29;
593
+ case 25: return 32;
559
594
  break;
560
- case 23: return 33;
595
+ case 26: return 31;
561
596
  break;
562
- case 24: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 33;
597
+ case 27: return 35;
563
598
  break;
564
- case 25: return 'INVALID';
599
+ case 28: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 35;
565
600
  break;
566
- case 26: return 5;
601
+ case 29: return 'INVALID';
602
+ break;
603
+ case 30: /*ignore whitespace*/
604
+ break;
605
+ case 31: this.popState(); return 37;
606
+ break;
607
+ case 32: return 5;
567
608
  break;
568
609
  }
569
610
  };
570
- lexer.rules = [/^[^\x00]*?(?=(\{\{))/,/^[^\x00]+/,/^[^\x00]{2,}?(?=(\{\{))/,/^\{\{>/,/^\{\{#/,/^\{\{\//,/^\{\{\^/,/^\{\{\s*else\b/,/^\{\{\{/,/^\{\{&/,/^\{\{![\s\S]*?\}\}/,/^\{\{/,/^=/,/^\.(?=[} ])/,/^\.\./,/^[\/.]/,/^\s+/,/^\}\}\}/,/^\}\}/,/^"(\\["]|[^"])*"/,/^true(?=[}\s])/,/^false(?=[}\s])/,/^[0-9]+(?=[}\s])/,/^[a-zA-Z0-9_$-]+(?=[=}\s\/.])/,/^\[[^\]]*\]/,/^./,/^$/];
571
- 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],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"INITIAL":{"rules":[0,1,26],"inclusive":true}};return lexer;})()
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}};
613
+ return lexer;})()
572
614
  parser.lexer = lexer;
573
- return parser;
574
- })();
575
- if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
576
- exports.parser = handlebars;
577
- exports.parse = function () { return handlebars.parse.apply(handlebars, arguments); }
578
- exports.main = function commonjsMain(args) {
579
- if (!args[1])
580
- throw new Error('Usage: '+args[0]+' FILE');
581
- if (typeof process !== 'undefined') {
582
- var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
583
- } else {
584
- var cwd = require("file").path(require("file").cwd());
585
- var source = cwd.join(args[1]).read({charset: "utf-8"});
586
- }
587
- return exports.parser.parse(source);
588
- }
589
- if (typeof module !== 'undefined' && require.main === module) {
590
- exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
591
- }
592
- };
593
- ;
615
+ function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
616
+ return new Parser;
617
+ })();;
594
618
  // lib/handlebars/compiler/base.js
595
619
  Handlebars.Parser = handlebars;
596
620
 
@@ -601,17 +625,7 @@ Handlebars.parse = function(string) {
601
625
 
602
626
  Handlebars.print = function(ast) {
603
627
  return new Handlebars.PrintVisitor().accept(ast);
604
- };
605
-
606
- Handlebars.logger = {
607
- DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
608
-
609
- // override in the host environment
610
- log: function(level, str) {}
611
- };
612
-
613
- Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
614
- ;
628
+ };;
615
629
  // lib/handlebars/compiler/ast.js
616
630
  (function() {
617
631
 
@@ -645,13 +659,10 @@ Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
645
659
  // pass or at runtime.
646
660
  };
647
661
 
648
- Handlebars.AST.PartialNode = function(id, context) {
649
- this.type = "partial";
650
-
651
- // TODO: disallow complex IDs
652
-
653
- this.id = id;
654
- this.context = context;
662
+ Handlebars.AST.PartialNode = function(partialName, context) {
663
+ this.type = "partial";
664
+ this.partialName = partialName;
665
+ this.context = context;
655
666
  };
656
667
 
657
668
  var verifyMatch = function(open, close) {
@@ -703,21 +714,36 @@ Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
703
714
  // an ID is simple if it only has one part, and that part is not
704
715
  // `..` or `this`.
705
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;
724
+ };
725
+
726
+ Handlebars.AST.DataNode = function(id) {
727
+ this.type = "DATA";
728
+ this.id = id;
706
729
  };
707
730
 
708
731
  Handlebars.AST.StringNode = function(string) {
709
732
  this.type = "STRING";
710
733
  this.string = string;
734
+ this.stringModeValue = string;
711
735
  };
712
736
 
713
737
  Handlebars.AST.IntegerNode = function(integer) {
714
738
  this.type = "INTEGER";
715
739
  this.integer = integer;
740
+ this.stringModeValue = Number(integer);
716
741
  };
717
742
 
718
743
  Handlebars.AST.BooleanNode = function(bool) {
719
744
  this.type = "BOOLEAN";
720
745
  this.bool = bool;
746
+ this.stringModeValue = bool === "true";
721
747
  };
722
748
 
723
749
  Handlebars.AST.CommentNode = function(comment) {
@@ -727,14 +753,16 @@ Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
727
753
 
728
754
  })();;
729
755
  // lib/handlebars/utils.js
756
+
757
+ var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
758
+
730
759
  Handlebars.Exception = function(message) {
731
760
  var tmp = Error.prototype.constructor.apply(this, arguments);
732
761
 
733
- for (var p in tmp) {
734
- 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]];
735
765
  }
736
-
737
- this.message = tmp.message;
738
766
  };
739
767
  Handlebars.Exception.prototype = new Error();
740
768
 
@@ -748,6 +776,7 @@ Handlebars.SafeString.prototype.toString = function() {
748
776
 
749
777
  (function() {
750
778
  var escape = {
779
+ "&": "&amp;",
751
780
  "<": "&lt;",
752
781
  ">": "&gt;",
753
782
  '"': "&quot;",
@@ -755,7 +784,7 @@ Handlebars.SafeString.prototype.toString = function() {
755
784
  "`": "&#x60;"
756
785
  };
757
786
 
758
- var badChars = /&(?!\w+;)|[<>"'`]/g;
787
+ var badChars = /[&<>"'`]/g;
759
788
  var possible = /[&<>"'`]/;
760
789
 
761
790
  var escapeChar = function(chr) {
@@ -776,11 +805,7 @@ Handlebars.SafeString.prototype.toString = function() {
776
805
  },
777
806
 
778
807
  isEmpty: function(value) {
779
- if (typeof value === "undefined") {
780
- return true;
781
- } else if (value === null) {
782
- return true;
783
- } else if (value === false) {
808
+ if (!value && value !== 0) {
784
809
  return true;
785
810
  } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
786
811
  return true;
@@ -919,7 +944,7 @@ Handlebars.JavaScriptCompiler = function() {};
919
944
  // evaluate it by executing `blockHelperMissing`
920
945
  this.opcode('pushProgram', program);
921
946
  this.opcode('pushProgram', inverse);
922
- this.opcode('pushLiteral', '{}');
947
+ this.opcode('pushHash');
923
948
  this.opcode('blockValue');
924
949
  } else {
925
950
  this.ambiguousMustache(mustache, program, inverse);
@@ -928,7 +953,7 @@ Handlebars.JavaScriptCompiler = function() {};
928
953
  // evaluate it by executing `blockHelperMissing`
929
954
  this.opcode('pushProgram', program);
930
955
  this.opcode('pushProgram', inverse);
931
- this.opcode('pushLiteral', '{}');
956
+ this.opcode('pushHash');
932
957
  this.opcode('ambiguousBlockValue');
933
958
  }
934
959
 
@@ -938,19 +963,24 @@ Handlebars.JavaScriptCompiler = function() {};
938
963
  hash: function(hash) {
939
964
  var pairs = hash.pairs, pair, val;
940
965
 
941
- this.opcode('push', '{}');
966
+ this.opcode('pushHash');
942
967
 
943
968
  for(var i=0, l=pairs.length; i<l; i++) {
944
969
  pair = pairs[i];
945
970
  val = pair[1];
946
971
 
947
- this.accept(val);
972
+ if (this.options.stringParams) {
973
+ this.opcode('pushStringParam', val.stringModeValue, val.type);
974
+ } else {
975
+ this.accept(val);
976
+ }
977
+
948
978
  this.opcode('assignToHash', pair[0]);
949
979
  }
950
980
  },
951
981
 
952
982
  partial: function(partial) {
953
- var id = partial.id;
983
+ var partialName = partial.partialName;
954
984
  this.usePartial = true;
955
985
 
956
986
  if(partial.context) {
@@ -959,7 +989,7 @@ Handlebars.JavaScriptCompiler = function() {};
959
989
  this.opcode('push', 'depth0');
960
990
  }
961
991
 
962
- this.opcode('invokePartial', id.original);
992
+ this.opcode('invokePartial', partialName.name);
963
993
  this.opcode('append');
964
994
  },
965
995
 
@@ -1000,17 +1030,17 @@ Handlebars.JavaScriptCompiler = function() {};
1000
1030
  simpleMustache: function(mustache, program, inverse) {
1001
1031
  var id = mustache.id;
1002
1032
 
1003
- this.addDepth(id.depth);
1004
- this.opcode('getContext', id.depth);
1005
-
1006
- if (id.parts.length) {
1007
- this.opcode('lookupOnContext', id.parts[0]);
1008
- for(var i=1, l=id.parts.length; i<l; i++) {
1009
- this.opcode('lookup', id.parts[i]);
1010
- }
1033
+ if (id.type === 'DATA') {
1034
+ this.DATA(id);
1035
+ } else if (id.parts.length) {
1036
+ this.ID(id);
1011
1037
  } else {
1038
+ // Simplified ID for `this`
1039
+ this.addDepth(id.depth);
1040
+ this.opcode('getContext', id.depth);
1012
1041
  this.opcode('pushContext');
1013
1042
  }
1043
+
1014
1044
  this.opcode('resolvePossibleLambda');
1015
1045
  },
1016
1046
 
@@ -1030,13 +1060,24 @@ Handlebars.JavaScriptCompiler = function() {};
1030
1060
  ID: function(id) {
1031
1061
  this.addDepth(id.depth);
1032
1062
  this.opcode('getContext', id.depth);
1033
- this.opcode('lookupOnContext', id.parts[0]);
1063
+
1064
+ var name = id.parts[0];
1065
+ if (!name) {
1066
+ this.opcode('pushContext');
1067
+ } else {
1068
+ this.opcode('lookupOnContext', id.parts[0]);
1069
+ }
1034
1070
 
1035
1071
  for(var i=1, l=id.parts.length; i<l; i++) {
1036
1072
  this.opcode('lookup', id.parts[i]);
1037
1073
  }
1038
1074
  },
1039
1075
 
1076
+ DATA: function(data) {
1077
+ this.options.data = true;
1078
+ this.opcode('lookupData', data.id);
1079
+ },
1080
+
1040
1081
  STRING: function(string) {
1041
1082
  this.opcode('pushString', string.string);
1042
1083
  },
@@ -1061,6 +1102,7 @@ Handlebars.JavaScriptCompiler = function() {};
1061
1102
  },
1062
1103
 
1063
1104
  addDepth: function(depth) {
1105
+ if(isNaN(depth)) { throw new Error("EWOT"); }
1064
1106
  if(depth === 0) { return; }
1065
1107
 
1066
1108
  if(!this.depths[depth]) {
@@ -1102,7 +1144,7 @@ Handlebars.JavaScriptCompiler = function() {};
1102
1144
  }
1103
1145
 
1104
1146
  this.opcode('getContext', param.depth || 0);
1105
- this.opcode('pushStringParam', param.string);
1147
+ this.opcode('pushStringParam', param.stringModeValue, param.type);
1106
1148
  } else {
1107
1149
  this[param.type](param);
1108
1150
  }
@@ -1116,7 +1158,7 @@ Handlebars.JavaScriptCompiler = function() {};
1116
1158
  if(mustache.hash) {
1117
1159
  this.hash(mustache.hash);
1118
1160
  } else {
1119
- this.opcode('pushLiteral', '{}');
1161
+ this.opcode('pushHash');
1120
1162
  }
1121
1163
 
1122
1164
  return params;
@@ -1133,7 +1175,7 @@ Handlebars.JavaScriptCompiler = function() {};
1133
1175
  if(mustache.hash) {
1134
1176
  this.hash(mustache.hash);
1135
1177
  } else {
1136
- this.opcode('pushLiteral', '{}');
1178
+ this.opcode('pushHash');
1137
1179
  }
1138
1180
 
1139
1181
  return params;
@@ -1227,7 +1269,8 @@ Handlebars.JavaScriptCompiler = function() {};
1227
1269
  if (!this.isChild) {
1228
1270
  var namespace = this.namespace;
1229
1271
  var copies = "helpers = helpers || " + namespace + ".helpers;";
1230
- if(this.environment.usePartial) { copies = copies + " partials = partials || " + namespace + ".partials;"; }
1272
+ if (this.environment.usePartial) { copies = copies + " partials = partials || " + namespace + ".partials;"; }
1273
+ if (this.options.data) { copies = copies + " data = data || {};"; }
1231
1274
  out.push(copies);
1232
1275
  } else {
1233
1276
  out.push('');
@@ -1307,7 +1350,7 @@ Handlebars.JavaScriptCompiler = function() {};
1307
1350
 
1308
1351
  this.replaceStack(function(current) {
1309
1352
  params.splice(1, 0, current);
1310
- return current + " = blockHelperMissing.call(" + params.join(", ") + ")";
1353
+ return "blockHelperMissing.call(" + params.join(", ") + ")";
1311
1354
  });
1312
1355
  },
1313
1356
 
@@ -1419,7 +1462,7 @@ Handlebars.JavaScriptCompiler = function() {};
1419
1462
  this.context.aliases.functionType = '"function"';
1420
1463
 
1421
1464
  this.replaceStack(function(current) {
1422
- return "typeof " + current + " === functionType ? " + current + "() : " + current;
1465
+ return "typeof " + current + " === functionType ? " + current + ".apply(depth0) : " + current;
1423
1466
  });
1424
1467
  },
1425
1468
 
@@ -1436,6 +1479,16 @@ Handlebars.JavaScriptCompiler = function() {};
1436
1479
  });
1437
1480
  },
1438
1481
 
1482
+ // [lookupData]
1483
+ //
1484
+ // On stack, before: ...
1485
+ // On stack, after: data[id], ...
1486
+ //
1487
+ // Push the result of looking up `id` on the current data
1488
+ lookupData: function(id) {
1489
+ this.pushStack(this.nameLookup('data', id, 'data'));
1490
+ },
1491
+
1439
1492
  // [pushStringParam]
1440
1493
  //
1441
1494
  // On stack, before: ...
@@ -1444,9 +1497,24 @@ Handlebars.JavaScriptCompiler = function() {};
1444
1497
  // This opcode is designed for use in string mode, which
1445
1498
  // provides the string value of a parameter along with its
1446
1499
  // depth rather than resolving it immediately.
1447
- pushStringParam: function(string) {
1500
+ pushStringParam: function(string, type) {
1448
1501
  this.pushStackLiteral('depth' + this.lastContext);
1449
- 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
+ }
1450
1518
  },
1451
1519
 
1452
1520
  // [pushString]
@@ -1554,7 +1622,7 @@ Handlebars.JavaScriptCompiler = function() {};
1554
1622
  var nextStack = this.nextStack();
1555
1623
 
1556
1624
  this.source.push('if (foundHelper) { ' + nextStack + ' = foundHelper.call(' + helper.callParams + '); }');
1557
- 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 + '; }');
1558
1626
  },
1559
1627
 
1560
1628
  // [invokePartial]
@@ -1572,7 +1640,7 @@ Handlebars.JavaScriptCompiler = function() {};
1572
1640
  }
1573
1641
 
1574
1642
  this.context.aliases.self = "this";
1575
- this.pushStack("self.invokePartial(" + params.join(", ") + ");");
1643
+ this.pushStack("self.invokePartial(" + params.join(", ") + ")");
1576
1644
  },
1577
1645
 
1578
1646
  // [assignToHash]
@@ -1584,6 +1652,13 @@ Handlebars.JavaScriptCompiler = function() {};
1584
1652
  // and pushes the hash back onto the stack.
1585
1653
  assignToHash: function(key) {
1586
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
+
1587
1662
  var hash = this.topStack();
1588
1663
 
1589
1664
  this.source.push(hash + "['" + key + "'] = " + value + ";");
@@ -1653,21 +1728,28 @@ Handlebars.JavaScriptCompiler = function() {};
1653
1728
  },
1654
1729
 
1655
1730
  pushStack: function(item) {
1656
- this.source.push(this.incrStack() + " = " + item + ";");
1657
- this.compileStack.push("stack" + this.stackSlot);
1658
- return "stack" + this.stackSlot;
1731
+ var stack = this.incrStack();
1732
+ this.source.push(stack + " = " + item + ";");
1733
+ this.compileStack.push(stack);
1734
+ return stack;
1659
1735
  },
1660
1736
 
1661
1737
  replaceStack: function(callback) {
1662
- var item = callback.call(this, this.topStack());
1738
+ var stack = this.topStack(),
1739
+ item = callback.call(this, stack);
1663
1740
 
1664
- this.source.push(this.topStack() + " = " + item + ";");
1665
- 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;
1666
1748
  },
1667
1749
 
1668
1750
  nextStack: function(skipCompileStack) {
1669
1751
  var name = this.incrStack();
1670
- this.compileStack.push("stack" + this.stackSlot);
1752
+ this.compileStack.push(name);
1671
1753
  return name;
1672
1754
  },
1673
1755
 
@@ -1722,7 +1804,7 @@ Handlebars.JavaScriptCompiler = function() {};
1722
1804
  // the params and contexts arguments are passed in arrays
1723
1805
  // to fill in
1724
1806
  setupParams: function(paramSize, params) {
1725
- var options = [], contexts = [], param, inverse, program;
1807
+ var options = [], contexts = [], types = [], param, inverse, program;
1726
1808
 
1727
1809
  options.push("hash:" + this.popStack());
1728
1810
 
@@ -1751,12 +1833,15 @@ Handlebars.JavaScriptCompiler = function() {};
1751
1833
  params.push(param);
1752
1834
 
1753
1835
  if(this.options.stringParams) {
1836
+ types.push(this.popStack());
1754
1837
  contexts.push(this.popStack());
1755
1838
  }
1756
1839
  }
1757
1840
 
1758
1841
  if (this.options.stringParams) {
1759
1842
  options.push("contexts:[" + contexts.join(",") + "]");
1843
+ options.push("types:[" + types.join(",") + "]");
1844
+ options.push("hashTypes:hashTypes");
1760
1845
  }
1761
1846
 
1762
1847
  if(this.options.data) {
@@ -1802,16 +1887,28 @@ Handlebars.JavaScriptCompiler = function() {};
1802
1887
  })(Handlebars.Compiler, Handlebars.JavaScriptCompiler);
1803
1888
 
1804
1889
  Handlebars.precompile = function(string, options) {
1805
- options = options || {};
1890
+ if (typeof string !== 'string') {
1891
+ throw new Handlebars.Exception("You must pass a string to Handlebars.compile. You passed " + string);
1892
+ }
1806
1893
 
1894
+ options = options || {};
1895
+ if (!('data' in options)) {
1896
+ options.data = true;
1897
+ }
1807
1898
  var ast = Handlebars.parse(string);
1808
1899
  var environment = new Handlebars.Compiler().compile(ast, options);
1809
1900
  return new Handlebars.JavaScriptCompiler().compile(environment, options);
1810
1901
  };
1811
1902
 
1812
1903
  Handlebars.compile = function(string, options) {
1813
- options = options || {};
1904
+ if (typeof string !== 'string') {
1905
+ throw new Handlebars.Exception("You must pass a string to Handlebars.compile. You passed " + string);
1906
+ }
1814
1907
 
1908
+ options = options || {};
1909
+ if (!('data' in options)) {
1910
+ options.data = true;
1911
+ }
1815
1912
  var compiled;
1816
1913
  function compile() {
1817
1914
  var ast = Handlebars.parse(string);
@@ -1885,7 +1982,7 @@ Handlebars.VM = {
1885
1982
  } else if (!Handlebars.compile) {
1886
1983
  throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
1887
1984
  } else {
1888
- partials[name] = Handlebars.compile(partial);
1985
+ partials[name] = Handlebars.compile(partial, {data: data !== undefined});
1889
1986
  return partials[name](context, options);
1890
1987
  }
1891
1988
  }