machty / emblem.js

Emblem.js - Ember-friendly, indented syntax alternative for Handlebars.js
http://emblemjs.com
MIT License
1.04k stars 81 forks source link

Bad AST with simple mistake #108

Closed smclelland closed 8 years ago

smclelland commented 10 years ago

Given this .emblem input


.my-class id="food" mistake
  ul
    li

The AST generated by calling.

Emble.parse(string);

Causes an exception down in the handlebar's compiler on line hb->compile.js:110

Uncaught TypeError: Property 'undefined' of object # is not a function

for(var i=0, l=statements.length; i<l; i++) {
  statement = statements[i];
  this[statement.type](statement);
}

Looks like in this case, Emble parse is confused by the mistake in there. It ends up with an AST that looks like:

0: {string: "<div class="my-class" id="it">mistake ul   li", type: "content"}
1: "\n"
2: {string: "</div>", type: "content"}

Since item 1 isn't a valid AST entry (missing .type), handlebars compile chokes on it.