Skip to content

Instantly share code, notes, and snippets.

@visnup
Created October 3, 2010 19:30
Show Gist options
  • Save visnup/608843 to your computer and use it in GitHub Desktop.
Save visnup/608843 to your computer and use it in GitHub Desktop.
I know: it's blasphemy. whatever.
// if you have the ruby sass gem installed, use the `sass` executable from it to
// generate css instead of the incomplete sass.js implementation.
express.compiler.compilers.sass.compile = function(str, fn) {
try {
var sass = require('child_process').spawn('sass', ['--stdin']),
append = function(data) { css += data; },
css = '';
sass.stdout.on('data', append);
sass.stderr.on('data', append);
sass.on('exit', function(code) {
if (code === 0)
fn(null, css);
else
fn(new Error('sass exited with code: ' + code + '\n' + css));
});
sass.stdin.write(new Buffer(str));
sass.stdin.end();
} catch(err) {
fn(err);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment