substack/attractor — pull request #3 by eugeneware (2014-03-15 08:18:47+00:00)
Title: Expose the attractor instance to the plugin to allow nesting

Currently if we have an attractor plugin that creates some HTML, and we want to then scan this generated HTML, and bind it (to do the equivalent of "transclusion" (or nesting) in angular.js for example), it's not simple to do as we can't easily get access to the `Attractor` class to be able to call `.scan()`, etc.

This change exposes the `Attractor` instance to the plugin, without breaking the API, so you can do stuff like:

``` html

Generated bind goes here

```

``` js
// app.js
var attr = require('attractor')({
binder: require('attr-bind'),
child: require('attr-generateChild')
});

attr.scan(document);
```

``` js
// attr-generateChild.js
module.exports = generateChild;
function generateChild(cb) {
return function (el) {
// generate a child with data binding and then rescan the doc to wire it up
el.innerHTML = '';
this.scan(document);
cb();
}
}
```