Przeglądaj źródła

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.
tags/0.2
Sebastian Cohnen 16 lat temu
rodzic
commit
45948113fa
4 zmienionych plików z 11 dodań i 8 usunięć
  1. +4
    -4
      examples/delimiters.html
  2. +2
    -1
      examples/delimiters.js
  3. +1
    -2
      examples/delimiters.txt
  4. +4
    -1
      mustache.js

+ 4
- 4
examples/delimiters.html Wyświetl plik

@@ -1,6 +1,6 @@
{{=<% %>=}}
* <% first %>
{{=<% %>=}}* <% first %>
* <% second %>
<%=| |=%> <%=| |=%>
* | second |
* | third |
|={{ }}=| |={{ }}=|
* {{ third }}
* {{ fourth }}

+ 2
- 1
examples/delimiters.js Wyświetl plik

@@ -1,5 +1,6 @@
var delimiters = { var delimiters = {
first: "It worked the first time.", first: "It worked the first time.",
second: "And it worked the second 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!."
} }

+ 1
- 2
examples/delimiters.txt Wyświetl plik

@@ -1,7 +1,6 @@

* It worked the first time. * It worked the first time.

* And it worked the second time. * And it worked the second time.


* Then, surprisingly, it worked the third time. * Then, surprisingly, it worked the third time.


* Fourth time also fine!.

+ 4
- 1
mustache.js Wyświetl plik

@@ -1,6 +1,7 @@
/* /*
Shamless port of http://github.com/defunkt/mustache Shamless port of http://github.com/defunkt/mustache
by Jan Lehnardt <jan@apache.org>, Alexander Lang <alex@upstream-berlin.com>
by Jan Lehnardt <jan@apache.org>, Alexander Lang <alex@upstream-berlin.com>,
Sebastian Cohnen <sebastian.cohnen@googlemail.com>


Thanks @defunkt for the awesome code. Thanks @defunkt for the awesome code.
@@ -106,6 +107,8 @@ var Mustache = function() {
case "=": // set new delimiters, rebuild the replace regexp case "=": // set new delimiters, rebuild the replace regexp
that.set_delimiters(name); that.set_delimiters(name);
regex = new_regex(); regex = new_regex();
// redo the line in order to get tags with the new delimiters on the same line
i--;
return ""; return "";
case "<": // render partial case "<": // render partial
return that.render_partial(name, context); return that.render_partial(name, context);


Ładowanie…
Anuluj
Zapisz