Permalink
Browse files

Merge pull request #72 from plecong/master

Fix Scanner Indexes of Section With Uneven Reset Delimiters
  • Loading branch information...
2 parents 4a5135d + c93da06 commit 7a7e38cab37d9a94a3d18d03a7f638ae8394ab37 @sayrer sayrer committed Apr 17, 2012
Showing with 15 additions and 1 deletion.
  1. +1 −1 lib/compiler.js
  2. +14 −0 test/index.js
View
@@ -135,7 +135,7 @@
} else {
if (tagChange(ctag, text, i)) {
tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
- i: (tagType == '/') ? seenTag - ctag.length : i + otag.length});
+ i: (tagType == '/') ? seenTag - otag.length : i + ctag.length});
buf = '';
i += ctag.length - 1;
state = IN_TEXT;
View
@@ -1066,3 +1066,17 @@ test("Default Render Impl", function() {
var ht = new Hogan.Template();
is(ht.render() === '', true, 'default renderImpl returns an array.');
});
+
+test("Section With Custom Uneven Delimiter Length", function() {
+ var text = '{{=<% %%>=}}Test<%#foo%%>bar<%/foo%%>';
+ var t = Hogan.compile(text);
+ var context = {
+ foo: function() {
+ return function(s) {
+ return "<b>" + s + "</b>";
+ }
+ }
+ }
+ var s = t.render(context);
+ is(s, 'Test<b>bar</b>', 'Section content is correct with uneven reset delimiter length');
+});

0 comments on commit 7a7e38c

Please sign in to comment.