From d4858fe7403eb5bcdba7d4d1341d391aa1321f26 Mon Sep 17 00:00:00 2001 From: Caolan McMahon Date: Tue, 7 Dec 2010 22:06:18 +0000 Subject: [PATCH 1/5] check for node.js not just commonjs environment when including server module --- lib/dust.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dust.js b/lib/dust.js index c60f52f..80d18ff 100644 --- a/lib/dust.js +++ b/lib/dust.js @@ -514,6 +514,8 @@ dust.escapeJs = function(s) { })(dust); if (typeof exports !== "undefined") { - require('./server')(dust); + if (typeof process !== "undefined") { + require('./server')(dust); + } module.exports = dust; } From 6d45b4401d80ca46a69d40ceefdc6e244046d3e7 Mon Sep 17 00:00:00 2001 From: Caolan McMahon Date: Tue, 7 Dec 2010 22:38:15 +0000 Subject: [PATCH 2/5] don't use literal RegExp syntax for HCHARS because couchdb doesn't like it for some reason --- lib/dust.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dust.js b/lib/dust.js index 80d18ff..0a146e5 100644 --- a/lib/dust.js +++ b/lib/dust.js @@ -469,7 +469,7 @@ Tap.prototype.go = function(value) { return value; }; -var HCHARS = /[&<>\"]/, +var HCHARS = new RegExp(/[&<>\"]/), AMP = /&/g, LT = //g, From cfb135b9167be21a4dd221baa0e9bcf4c31f0546 Mon Sep 17 00:00:00 2001 From: akdubya Date: Fri, 17 Dec 2010 15:21:48 +0800 Subject: [PATCH 3/5] fix global variable leak --- lib/dust.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dust.js b/lib/dust.js index 0a146e5..78253e1 100644 --- a/lib/dust.js +++ b/lib/dust.js @@ -38,7 +38,7 @@ dust.compileFn = function(source, name) { }; dust.load = function(name, chunk, context) { - tmpl = dust.cache[name]; + var tmpl = dust.cache[name]; if (tmpl) { return tmpl(chunk, context); } else { From 7df0f7de8d7722681f5f6becbd2862f50f52b440 Mon Sep 17 00:00:00 2001 From: Caolan McMahon Date: Mon, 20 Dec 2010 02:30:19 +0000 Subject: [PATCH 4/5] export optimizers in commonsjs environment too --- lib/server.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index 8fe4192..122bba2 100644 --- a/lib/server.js +++ b/lib/server.js @@ -14,4 +14,7 @@ module.exports = function(dust) { }; dust.nextTick = process.nextTick; -} \ No newline at end of file + + // expose optimizers in commonjs env too + dust.optimizers = compiler.optimizers; +} From b8a49b4ce405fe9fd9465df40d02c07476b35671 Mon Sep 17 00:00:00 2001 From: Caolan McMahon Date: Mon, 21 Nov 2011 13:54:36 -0800 Subject: [PATCH 5/5] require.paths has been removed in node 0.6.x, comment out unshift call in lib/server.js --- lib/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index 6c8e48f..aeb43b0 100644 --- a/lib/server.js +++ b/lib/server.js @@ -3,7 +3,7 @@ var path = require('path'), compiler = require('./compiler'), vm = require('vm'); -require.paths.unshift(path.join(__dirname, '..')); +//require.paths.unshift(path.join(__dirname, '..')); module.exports = function(dust) { compiler.parse = parser.parse;