Pārlūkot izejas kodu

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 pirms 16 gadiem
vecāks
revīzija
45948113fa
4 mainītis faili ar 11 papildinājumiem un 8 dzēšanām
  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 Parādīt failu

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

+ 2
- 1
examples/delimiters.js Parādīt failu

@@ -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!."
}

+ 1
- 2
examples/delimiters.txt Parādīt failu

@@ -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!.

+ 4
- 1
mustache.js Parādīt failu

@@ -1,6 +1,7 @@
/*
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.
@@ -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);


Notiek ielāde…
Atcelt
Saglabāt