Tested that safestrings don't get escaped.
This commit is contained in:
+5
-1
@@ -10,7 +10,11 @@ Handlebars = {
|
||||
},
|
||||
|
||||
escape: function(string) {
|
||||
if (string === null) {
|
||||
// don't escape SafeStrings, since they're already safe
|
||||
if (string instanceof Handlebars.SafeString) {
|
||||
return string.toString();
|
||||
}
|
||||
else if (string === null) {
|
||||
string = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,13 @@ test("escaping", function() {
|
||||
|
||||
shouldCompileTo("{{&awesome}}", {awesome: "&\"\\<>"}, '&\"\\<>',
|
||||
"expressions with {{& handlebars aren't escaped");
|
||||
|
||||
});
|
||||
|
||||
test("functions returning safestrings shouldn't be escaped", function() {
|
||||
var hash = {awesome: function() { return new Handlebars.SafeString("&\"\\<>"); }};
|
||||
shouldCompileTo("{{awesome}}", hash, '&\"\\<>',
|
||||
"functions returning safestrings aren't escaped");
|
||||
});
|
||||
|
||||
test("functions", function() {
|
||||
|
||||
Reference in New Issue
Block a user