Skip to content

Commit 4cca9a8

Browse files
committed
even more helpful LiveUI message on mismatched tags
1 parent edea43e commit 4cca9a8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/liveui/liveui.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,23 @@ Meteor.ui = Meteor.ui || {};
8282
endNode === startNode.parentNode.nextSibling) {
8383
endNode = startNode.parentNode.lastChild;
8484
} else {
85+
var r = new RegExp('<!--\\s*STARTRANGE_'+id+'.*?-->', 'g');
86+
var match = r.exec(html);
87+
var help = "";
88+
if (match) {
89+
var comment_end = r.lastIndex;
90+
var comment_start = comment_end - match[0].length;
91+
var stripped_before = html.slice(0, comment_start).replace(
92+
/<!--\s*(START|END)RANGE.*?-->/g, '');
93+
var stripped_after = html.slice(comment_end).replace(
94+
/<!--\s*(START|END)RANGE.*?-->/g, '');
95+
var context_amount = 50;
96+
var context = stripped_before.slice(-context_amount) +
97+
stripped_after.slice(0, context_amount);
98+
help = " (possible unclosed near: "+context+")";
99+
}
85100
throw new Error("Could not create liverange in template. "+
86-
"Check for unclosed tags in your HTML.");
101+
"Check for unclosed tags in your HTML."+help);
87102
}
88103
}
89104

0 commit comments

Comments
 (0)