var types = ddt.types; while(this.i < this.contents.length){ var token = this.contents[this.i++]; if(token[0] == types.tag && token[1] == endtag){ return; } } throw new Error("Unclosed tag found when looking for " + endtag);