kriszyp/put-selector — Issue #3: put.getDocument
Author: neonstalwart
Created: 2011-12-19 22:20:56+00:00
State: open

this is low priority - mostly looking for feedback since its just for a POC.

after looking at node-html.js i came to the realization that i could use put to build an ast if i give it an appropriate object as a document. my idea is that i want to parse something like `div#{{id}}` into an ast and then render that with a context like `{ id: 'identity' }` to build and manipulate DOM nodes. for example

```js
var context = new Stateful({ id: 'identity' });
var node = magic.render('div#{{id}}', context); // creates a node with id="identity" and watches context for changes
put(parent, node); // node is added to a parent
context.set('id', 'changed'); // has the same effect as put(node, '#changed);
```

the idea is to parse a whole tree like this but only update each node based on changes to the context.

during `magic.render` i'll set the document to be something that will build an AST for me. then after that i want to set it back to the proper `document`. of course, i know that it should be `document` but the right thing to do would be to get whatever the document is before i change it, remember that and then change it back when i'm done. so for that, i'm suggesting `put.getDocument`.

as an aside, in case you try this, `'div#{{id}}'` fails to parse but i'm able to trick `put` into parsing `'div#$id'` (maybe that's a bug). also, if you're interested in exploring this idea with me i'd be glad to get your input.