ソースを参照

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

tags/0.3.0
Jan Lehnardt 16年前
コミット
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 = {
title: function() {
return "Bear > Shark";
}
},
entities: "&quot;"
};

+ 1
- 0
examples/escaped.txt ファイルの表示

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

+ 1
- 1
mustache.js ファイルの表示

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


読み込み中…
キャンセル
保存