templebars 0.2.1 → 0.2.2

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.
data/README.md CHANGED
@@ -70,6 +70,7 @@ config.templebars_template_global = "Ember.TEMPLATES"
70
70
 
71
71
  # Version History
72
72
 
73
+ * **0.2.2** Update Handlebars to a custom 1.0.rc.1 build, which fixes [issue #317](https://github.com/wycats/handlebars.js/issues/317).
73
74
  * **0.2.1** Update execjs and sprockets dependencies.
74
75
  * **0.2.0** Update Handlebars to 1.0.rc.1.
75
76
 
@@ -1,6 +1,6 @@
1
1
  module Templebars
2
2
  module Rails
3
- VERSION = "0.2.1"
4
- HANDLEBARSJS_VERSION = "1.0.rc.1"
3
+ VERSION = "0.2.2"
4
+ HANDLEBARSJS_VERSION = "1.0.rc.1 custom"
5
5
  end
6
6
  end
@@ -216,115 +216,195 @@ parseError: function parseError(str, hash) {
216
216
  throw new Error(str);
217
217
  },
218
218
  parse: function parse(input) {
219
- var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
219
+ var self = this,
220
+ stack = [0],
221
+ vstack = [null], // semantic value stack
222
+ lstack = [], // location stack
223
+ table = this.table,
224
+ yytext = '',
225
+ yylineno = 0,
226
+ yyleng = 0,
227
+ recovering = 0,
228
+ TERROR = 2,
229
+ EOF = 1;
230
+
231
+ //this.reductionCount = this.shiftCount = 0;
232
+
220
233
  this.lexer.setInput(input);
221
234
  this.lexer.yy = this.yy;
222
235
  this.yy.lexer = this.lexer;
223
- this.yy.parser = this;
224
- if (typeof this.lexer.yylloc == "undefined")
236
+ if (typeof this.lexer.yylloc == 'undefined')
225
237
  this.lexer.yylloc = {};
226
238
  var yyloc = this.lexer.yylloc;
227
239
  lstack.push(yyloc);
228
- var ranges = this.lexer.options && this.lexer.options.ranges;
229
- if (typeof this.yy.parseError === "function")
240
+
241
+ if (typeof this.yy.parseError === 'function')
230
242
  this.parseError = this.yy.parseError;
231
- function popStack(n) {
232
- stack.length = stack.length - 2 * n;
243
+
244
+ function popStack (n) {
245
+ stack.length = stack.length - 2*n;
233
246
  vstack.length = vstack.length - n;
234
247
  lstack.length = lstack.length - n;
235
248
  }
249
+
236
250
  function lex() {
237
251
  var token;
238
- token = self.lexer.lex() || 1;
239
- if (typeof token !== "number") {
252
+ token = self.lexer.lex() || 1; // $end = 1
253
+ // if token isn't its numeric value, convert
254
+ if (typeof token !== 'number') {
240
255
  token = self.symbols_[token] || token;
241
256
  }
242
257
  return token;
243
258
  }
244
- var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
259
+
260
+ var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
245
261
  while (true) {
246
- state = stack[stack.length - 1];
262
+ // retreive state number from top of stack
263
+ state = stack[stack.length-1];
264
+
265
+ // use default actions if available
247
266
  if (this.defaultActions[state]) {
248
267
  action = this.defaultActions[state];
249
268
  } else {
250
- if (symbol === null || typeof symbol == "undefined") {
269
+ if (symbol == null)
251
270
  symbol = lex();
252
- }
271
+ // read action for current state and first input
253
272
  action = table[state] && table[state][symbol];
254
273
  }
255
- if (typeof action === "undefined" || !action.length || !action[0]) {
256
- var errStr = "";
274
+
275
+ // handle parse error
276
+ _handle_error:
277
+ if (typeof action === 'undefined' || !action.length || !action[0]) {
278
+
257
279
  if (!recovering) {
280
+ // Report error
258
281
  expected = [];
259
- for (p in table[state])
260
- if (this.terminals_[p] && p > 2) {
261
- expected.push("'" + this.terminals_[p] + "'");
262
- }
282
+ for (p in table[state]) if (this.terminals_[p] && p > 2) {
283
+ expected.push("'"+this.terminals_[p]+"'");
284
+ }
285
+ var errStr = '';
263
286
  if (this.lexer.showPosition) {
264
- errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
287
+ errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
265
288
  } else {
266
- errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'");
289
+ errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
290
+ (symbol == 1 /*EOF*/ ? "end of input" :
291
+ ("'"+(this.terminals_[symbol] || symbol)+"'"));
267
292
  }
268
- this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
293
+ this.parseError(errStr,
294
+ {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
269
295
  }
270
- }
271
- if (action[0] instanceof Array && action.length > 1) {
272
- throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
273
- }
274
- switch (action[0]) {
275
- case 1:
276
- stack.push(symbol);
277
- vstack.push(this.lexer.yytext);
278
- lstack.push(this.lexer.yylloc);
279
- stack.push(action[1]);
280
- symbol = null;
281
- if (!preErrorSymbol) {
296
+
297
+ // just recovered from another error
298
+ if (recovering == 3) {
299
+ if (symbol == EOF) {
300
+ throw new Error(errStr || 'Parsing halted.');
301
+ }
302
+
303
+ // discard current lookahead and grab another
282
304
  yyleng = this.lexer.yyleng;
283
305
  yytext = this.lexer.yytext;
284
306
  yylineno = this.lexer.yylineno;
285
307
  yyloc = this.lexer.yylloc;
286
- if (recovering > 0)
287
- recovering--;
288
- } else {
289
- symbol = preErrorSymbol;
290
- preErrorSymbol = null;
291
- }
292
- break;
293
- case 2:
294
- len = this.productions_[action[1]][1];
295
- yyval.$ = vstack[vstack.length - len];
296
- 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};
297
- if (ranges) {
298
- yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
299
- }
300
- r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
301
- if (typeof r !== "undefined") {
302
- return r;
308
+ symbol = lex();
303
309
  }
304
- if (len) {
305
- stack = stack.slice(0, -1 * len * 2);
306
- vstack = vstack.slice(0, -1 * len);
307
- lstack = lstack.slice(0, -1 * len);
310
+
311
+ // try to recover from error
312
+ while (1) {
313
+ // check for error recovery rule in this state
314
+ if ((TERROR.toString()) in table[state]) {
315
+ break;
316
+ }
317
+ if (state == 0) {
318
+ throw new Error(errStr || 'Parsing halted.');
319
+ }
320
+ popStack(1);
321
+ state = stack[stack.length-1];
308
322
  }
309
- stack.push(this.productions_[action[1]][0]);
310
- vstack.push(yyval.$);
311
- lstack.push(yyval._$);
312
- newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
313
- stack.push(newState);
314
- break;
315
- case 3:
316
- return true;
323
+
324
+ preErrorSymbol = symbol; // save the lookahead token
325
+ symbol = TERROR; // insert generic error symbol as new lookahead
326
+ state = stack[stack.length-1];
327
+ action = table[state] && table[state][TERROR];
328
+ recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
317
329
  }
330
+
331
+ // this shouldn't happen, unless resolve defaults are off
332
+ if (action[0] instanceof Array && action.length > 1) {
333
+ throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
334
+ }
335
+
336
+ switch (action[0]) {
337
+
338
+ case 1: // shift
339
+ //this.shiftCount++;
340
+
341
+ stack.push(symbol);
342
+ vstack.push(this.lexer.yytext);
343
+ lstack.push(this.lexer.yylloc);
344
+ stack.push(action[1]); // push state
345
+ symbol = null;
346
+ if (!preErrorSymbol) { // normal execution/no error
347
+ yyleng = this.lexer.yyleng;
348
+ yytext = this.lexer.yytext;
349
+ yylineno = this.lexer.yylineno;
350
+ yyloc = this.lexer.yylloc;
351
+ if (recovering > 0)
352
+ recovering--;
353
+ } else { // error just occurred, resume old lookahead f/ before error
354
+ symbol = preErrorSymbol;
355
+ preErrorSymbol = null;
356
+ }
357
+ break;
358
+
359
+ case 2: // reduce
360
+ //this.reductionCount++;
361
+
362
+ len = this.productions_[action[1]][1];
363
+
364
+ // perform semantic action
365
+ yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
366
+ // default location, uses first token for firsts, last for lasts
367
+ yyval._$ = {
368
+ first_line: lstack[lstack.length-(len||1)].first_line,
369
+ last_line: lstack[lstack.length-1].last_line,
370
+ first_column: lstack[lstack.length-(len||1)].first_column,
371
+ last_column: lstack[lstack.length-1].last_column
372
+ };
373
+ r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
374
+
375
+ if (typeof r !== 'undefined') {
376
+ return r;
377
+ }
378
+
379
+ // pop off stack
380
+ if (len) {
381
+ stack = stack.slice(0,-1*len*2);
382
+ vstack = vstack.slice(0, -1*len);
383
+ lstack = lstack.slice(0, -1*len);
384
+ }
385
+
386
+ stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
387
+ vstack.push(yyval.$);
388
+ lstack.push(yyval._$);
389
+ // goto new state = table[STATE][NONTERMINAL]
390
+ newState = table[stack[stack.length-2]][stack[stack.length-1]];
391
+ stack.push(newState);
392
+ break;
393
+
394
+ case 3: // accept
395
+ return true;
396
+ }
397
+
318
398
  }
399
+
319
400
  return true;
320
- }
321
- };
401
+ }};
322
402
  /* Jison generated lexer */
323
403
  var lexer = (function(){
324
404
  var lexer = ({EOF:1,
325
405
  parseError:function parseError(str, hash) {
326
- if (this.yy.parser) {
327
- this.yy.parser.parseError(str, hash);
406
+ if (this.yy.parseError) {
407
+ this.yy.parseError(str, hash);
328
408
  } else {
329
409
  throw new Error(str);
330
410
  }
@@ -336,55 +416,21 @@ setInput:function (input) {
336
416
  this.yytext = this.matched = this.match = '';
337
417
  this.conditionStack = ['INITIAL'];
338
418
  this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
339
- if (this.options.ranges) this.yylloc.range = [0,0];
340
- this.offset = 0;
341
419
  return this;
342
420
  },
343
421
  input:function () {
344
422
  var ch = this._input[0];
345
- this.yytext += ch;
423
+ this.yytext+=ch;
346
424
  this.yyleng++;
347
- this.offset++;
348
- this.match += ch;
349
- this.matched += ch;
350
- var lines = ch.match(/(?:\r\n?|\n).*/g);
351
- if (lines) {
352
- this.yylineno++;
353
- this.yylloc.last_line++;
354
- } else {
355
- this.yylloc.last_column++;
356
- }
357
- if (this.options.ranges) this.yylloc.range[1]++;
358
-
425
+ this.match+=ch;
426
+ this.matched+=ch;
427
+ var lines = ch.match(/\n/);
428
+ if (lines) this.yylineno++;
359
429
  this._input = this._input.slice(1);
360
430
  return ch;
361
431
  },
362
432
  unput:function (ch) {
363
- var len = ch.length;
364
- var lines = ch.split(/(?:\r\n?|\n)/g);
365
-
366
433
  this._input = ch + this._input;
367
- this.yytext = this.yytext.substr(0, this.yytext.length-len-1);
368
- //this.yyleng -= len;
369
- this.offset -= len;
370
- var oldLines = this.match.split(/(?:\r\n?|\n)/g);
371
- this.match = this.match.substr(0, this.match.length-1);
372
- this.matched = this.matched.substr(0, this.matched.length-1);
373
-
374
- if (lines.length-1) this.yylineno -= lines.length-1;
375
- var r = this.yylloc.range;
376
-
377
- this.yylloc = {first_line: this.yylloc.first_line,
378
- last_line: this.yylineno+1,
379
- first_column: this.yylloc.first_column,
380
- last_column: lines ?
381
- (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length:
382
- this.yylloc.first_column - len
383
- };
384
-
385
- if (this.options.ranges) {
386
- this.yylloc.range = [r[0], r[0] + this.yyleng - len];
387
- }
388
434
  return this;
389
435
  },
390
436
  more:function () {
@@ -392,7 +438,7 @@ more:function () {
392
438
  return this;
393
439
  },
394
440
  less:function (n) {
395
- this.unput(this.match.slice(n));
441
+ this._input = this.match.slice(n) + this._input;
396
442
  },
397
443
  pastInput:function () {
398
444
  var past = this.matched.substr(0, this.matched.length - this.match.length);
@@ -436,31 +482,26 @@ next:function () {
436
482
  }
437
483
  }
438
484
  if (match) {
439
- lines = match[0].match(/(?:\r\n?|\n).*/g);
485
+ lines = match[0].match(/\n.*/g);
440
486
  if (lines) this.yylineno += lines.length;
441
487
  this.yylloc = {first_line: this.yylloc.last_line,
442
488
  last_line: this.yylineno+1,
443
489
  first_column: this.yylloc.last_column,
444
- last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length};
490
+ last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}
445
491
  this.yytext += match[0];
446
492
  this.match += match[0];
447
- this.matches = match;
448
493
  this.yyleng = this.yytext.length;
449
- if (this.options.ranges) {
450
- this.yylloc.range = [this.offset, this.offset += this.yyleng];
451
- }
452
494
  this._more = false;
453
495
  this._input = this._input.slice(match[0].length);
454
496
  this.matched += match[0];
455
497
  token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
456
- if (this.done && this._input) this.done = false;
457
498
  if (token) return token;
458
499
  else return;
459
500
  }
460
501
  if (this._input === "") {
461
502
  return this.EOF;
462
503
  } else {
463
- return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
504
+ this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
464
505
  {text: "", token: null, line: this.yylineno});
465
506
  }
466
507
  },
@@ -560,25 +601,23 @@ case 28: return 5;
560
601
  break;
561
602
  }
562
603
  };
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\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
604
+ 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
605
  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}};
565
606
  return lexer;})()
566
607
  parser.lexer = lexer;
567
- function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
568
- return new Parser;
608
+ return parser;
569
609
  })();
570
610
  if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
571
611
  exports.parser = handlebars;
572
- exports.Parser = handlebars.Parser;
573
612
  exports.parse = function () { return handlebars.parse.apply(handlebars, arguments); }
574
613
  exports.main = function commonjsMain(args) {
575
614
  if (!args[1])
576
615
  throw new Error('Usage: '+args[0]+' FILE');
577
- var source, cwd;
578
616
  if (typeof process !== 'undefined') {
579
- source = require('fs').readFileSync(require('path').resolve(args[1]), "utf8");
617
+ var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
580
618
  } else {
581
- source = require("file").path(require("file").cwd()).join(args[1]).read({charset: "utf-8"});
619
+ var cwd = require("file").path(require("file").cwd());
620
+ var source = cwd.join(args[1]).read({charset: "utf-8"});
582
621
  }
583
622
  return exports.parser.parse(source);
584
623
  }
@@ -1434,7 +1473,7 @@ Handlebars.JavaScriptCompiler = function() {};
1434
1473
  this.context.aliases.functionType = '"function"';
1435
1474
 
1436
1475
  this.replaceStack(function(current) {
1437
- return "typeof " + current + " === functionType ? " + current + "() : " + current;
1476
+ return "typeof " + current + " === functionType ? " + current + ".apply(depth0) : " + current;
1438
1477
  });
1439
1478
  },
1440
1479
 
@@ -1579,7 +1618,7 @@ Handlebars.JavaScriptCompiler = function() {};
1579
1618
  var nextStack = this.nextStack();
1580
1619
 
1581
1620
  this.source.push('if (foundHelper) { ' + nextStack + ' = foundHelper.call(' + helper.callParams + '); }');
1582
- this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '() : ' + nextStack + '; }');
1621
+ this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '.apply(depth0) : ' + nextStack + '; }');
1583
1622
  },
1584
1623
 
1585
1624
  // [invokePartial]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: templebars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-17 00:00:00.000000000 Z
12
+ date: 2012-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets