Closed neonstalwart closed 12 years ago
In https://github.com/kriszyp/put-selector/tree/forDocument you could do:
var normalPut = require("put-selector"); var magicPut = normalPut.forDocument(specialDocument);
What do you think about that?
yeah, i like that a LOT.
btw, regarding the experiment... https://github.com/twitter/hogan.js parses mustache and returns a tree. this is likely to really help push things along (once i get some time).
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 examplethe 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 properdocument
. of course, i know that it should bedocument
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 suggestingput.getDocument
.as an aside, in case you try this,
'div#{{id}}'
fails to parse but i'm able to trickput
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.