{"issue":{"milestone":null,"user":{"id":84763,"login":"neonstalwart","url":"https://api.github.com/users/neonstalwart","avatar_url":"https://secure.gravatar.com/avatar/4625cc3a305e2a7c2ccb902b5da5de04?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"4625cc3a305e2a7c2ccb902b5da5de04"},"created_at":"2011-12-19T22:20:56Z","title":"put.getDocument","labels":[],"state":"open","updated_at":"2011-12-19T22:20:56Z","id":2606693,"closed_at":null,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"html_url":"https://github.com/kriszyp/put-selector/issues/3","body":"this is low priority - mostly looking for feedback since its just for a POC.\r\n\r\nafter 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\r\n\r\n```js\r\nvar context = new Stateful({ id: 'identity' });\r\nvar node = magic.render('div#{{id}}', context); // creates a node with id=\"identity\" and watches context for changes\r\nput(parent, node); // node is added to a parent\r\ncontext.set('id', 'changed'); // has the same effect as put(node, '#changed);\r\n```\r\n\r\nthe idea is to parse a whole tree like this but only update each node based on changes to the context.\r\n\r\nduring `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`.\r\n\r\nas 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.","number":3,"url":"https://api.github.com/repos/kriszyp/put-selector/issues/3","comments":0,"assignee":null},"action":"opened"}