adunkman/connect-assets — pull request #182 by unknownexception (2013-03-18 05:05:16+00:00)
Title: Add `stylusExtends` option for support Stylus Javascript API

It is about using [Stylus Javascript API](http://learnboost.github.com/stylus/docs/js.html) with connect-assets in the following style:
```
app.use(connectAssets({
src: assetsSrc,
buildDir: '/html/',
stylusExtends: stylusExtendExampleLib
}))
```

For example, I have the function `stylusExtendExampleLib` with method `importRemote`, which allow remote including *.styl files into each others.

```
var stylusExtendExampleLib = function(style){
style.define('importRemote', function(remoteFile){
var context = this;
downloadStyl(remoteFile.val, function(toImport) {
var body,
block = context.currentBlock,
node = new stylus.nodes.String(toImport),
expr = new stylus.nodes.Expression();
expr.push(node);
body = context.visitImport(new stylus.nodes.Import(expr));
context.mixin(body.nodes, block);
style.define('importRemote', body.Nodes);
});

});
};
```
(where `downloadStyl` simply is a async function `(filename, callback)' which download file from common repository if needed).

I'm a newbie in javascript and especcially in coffeescript (actually, we use compiled version of `connect-assets` in production with many fixes), and I will be grateful for any corrections of these 2 lines of code.