Просмотр исходного кода

don't doublt encode entities. Closes #19. Patch by Leeoniya

tags/0.3.0
Jan Lehnardt 16 лет назад
Родитель
Сommit
8df3bef014
4 измененных файлов: 6 добавлений и 3 удалений
  1. +2
    -1
      examples/escaped.html
  2. +2
    -1
      examples/escaped.js
  3. +1
    -0
      examples/escaped.txt
  4. +1
    -1
      mustache.js

+ 2
- 1
examples/escaped.html Просмотреть файл

@@ -1 +1,2 @@
<h1>{{title}}</h1>
<h1>{{title}}</h1>
But not {{entities}}.

+ 2
- 1
examples/escaped.js Просмотреть файл

@@ -1,5 +1,6 @@
var escaped = { var escaped = {
title: function() { title: function() {
return "Bear > Shark"; return "Bear > Shark";
}
},
entities: "&quot;"
}; };

+ 1
- 0
examples/escaped.txt Просмотреть файл

@@ -1 +1,2 @@
<h1>Bear &gt; Shark</h1> <h1>Bear &gt; Shark</h1>
But not &quot;.

+ 1
- 1
mustache.js Просмотреть файл

@@ -208,7 +208,7 @@ var Mustache = function() {
Does away with nasty characters Does away with nasty characters
*/ */
escape: function(s) { escape: function(s) {
return ((s == null) ? "" : s).toString().replace(/[&"<>\\]/g, function(s) {
return ((s == null) ? "" : s).toString().replace(/&(?!\w+;)|["<>\\]/g, function(s) {
switch(s) { switch(s) {
case "&": return "&amp;"; case "&": return "&amp;";
case "\\": return "\\\\";; case "\\": return "\\\\";;


Загрузка…
Отмена
Сохранить