From e53ce34af442d4d4b8cc3074c569e1a56e1b66ac Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Tue, 12 Jun 2012 15:25:35 -0700 Subject: [PATCH] Fix quote implementation for environments without JSON.stringify --- mustache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mustache.js b/mustache.js index c5be0c9..3535e66 100644 --- a/mustache.js +++ b/mustache.js @@ -47,7 +47,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {}; }; var quote = (typeof JSON !== "undefined" && JSON.stringify) || function (string) { - return '"' + String(string).replace(/(^|[^\\])"/g, '\\"') + '"'; + return '"' + String(string).replace(/([\\"])/g, '\\$1') + '"'; }; function escapeRe(string) {