Skip to content

Commit

Permalink
permit post-processing callbacks bound to the stylus.render() 'end' e…
Browse files Browse the repository at this point in the history
…vent

to extend callback flow and modify the css result.
  • Loading branch information
mikesmullin committed Dec 2, 2012
1 parent c2b56a9 commit b672aa9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/renderer.js
Expand Up @@ -76,8 +76,12 @@ Renderer.prototype.render = function(fn){
var compiler = new Compiler(ast, this.options)
, css = compiler.compile();

this.emit('end', css);
fn(null, css);
if (!this.listeners('end').length) {
return fn(null, css);
}
this.emit('end', css, function(err, css) {
fn(err, css);
});
} catch (err) {
var options = {};
options.input = err.input || this.str;
Expand Down

0 comments on commit b672aa9

Please sign in to comment.