diff --git a/lib/compiler.js b/lib/compiler.js
index <HASH>..<HASH> 100644
--- a/lib/compiler.js
+++ b/lib/compiler.js
@@ -191,7 +191,8 @@ Compiler.prototype = {
     if (filter.isASTFilter) {
       this.buf.push(fn(filter.block, this, filter.attrs));
     } else {
-      this.buffer(fn(utils.text(filter.block.nodes.join('')), filter.attrs));
+      var text = filter.block.nodes.join('');
+      this.buffer(utils.text(fn(text, filter.attrs)));
     }
   },
   
diff --git a/test/filters.test.js b/test/filters.test.js
index <HASH>..<HASH> 100644
--- a/test/filters.test.js
+++ b/test/filters.test.js
@@ -83,6 +83,9 @@ module.exports = {
         assert.equal(
             '<script type="text/javascript">\n' + js + '\n</script>',
             render(':coffeescript\n  square = (x) ->\n    x * x'));
+
+        assert.equal('<script type="text/javascript">\n(function() {\n  alert(\'test\');\n}).call(this);\n</script>'
+          , render(":coffeescript\n  alert 'test'"));
     },
     
     'test parse tree': function(assert){
Fixed single-quote filter escape bug. Closes #<I>

escape quotes _after_ passing to filter