From 45948113fa397199fd0a8441b28d0fd62d1257dc Mon Sep 17 00:00:00 2001 From: Sebastian Cohnen Date: Sun, 18 Oct 2009 12:15:28 +0100 Subject: [PATCH] Fixed changing the delimiter Changing the delimiter and use the new one on the same line was broken. Fixed that and extended the test suite. --- examples/delimiters.html | 8 ++++---- examples/delimiters.js | 3 ++- examples/delimiters.txt | 3 +-- mustache.js | 5 ++++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/delimiters.html b/examples/delimiters.html index 92bea6d..f3d934b 100644 --- a/examples/delimiters.html +++ b/examples/delimiters.html @@ -1,6 +1,6 @@ -{{=<% %>=}} -* <% first %> +{{=<% %>=}}* <% first %> +* <% second %> <%=| |=%> -* | second | +* | third | |={{ }}=| -* {{ third }} +* {{ fourth }} \ No newline at end of file diff --git a/examples/delimiters.js b/examples/delimiters.js index 8d56dcd..220d0d2 100644 --- a/examples/delimiters.js +++ b/examples/delimiters.js @@ -1,5 +1,6 @@ var delimiters = { first: "It worked the first time.", second: "And it worked the second time.", - third: "Then, surprisingly, it worked the third time." + third: "Then, surprisingly, it worked the third time.", + fourth: "Fourth time also fine!." } diff --git a/examples/delimiters.txt b/examples/delimiters.txt index e95cd11..9313445 100644 --- a/examples/delimiters.txt +++ b/examples/delimiters.txt @@ -1,7 +1,6 @@ - * It worked the first time. - * And it worked the second time. * Then, surprisingly, it worked the third time. +* Fourth time also fine!. diff --git a/mustache.js b/mustache.js index 6618961..6f2bb52 100644 --- a/mustache.js +++ b/mustache.js @@ -1,6 +1,7 @@ /* Shamless port of http://github.com/defunkt/mustache - by Jan Lehnardt , Alexander Lang + by Jan Lehnardt , Alexander Lang , + Sebastian Cohnen Thanks @defunkt for the awesome code. @@ -106,6 +107,8 @@ var Mustache = function() { case "=": // set new delimiters, rebuild the replace regexp that.set_delimiters(name); regex = new_regex(); + // redo the line in order to get tags with the new delimiters on the same line + i--; return ""; case "<": // render partial return that.render_partial(name, context);