瀏覽代碼

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 "\\\\";;


Loading…
取消
儲存