-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to use 'at' on snippets #36
Comments
Not sure I can fix this. Defsnippet and Deftemplate return DocumentFragments(DF) objects. you can perform some actions on but not all. The DF object has to be added to the live dom to do all actions on it. I do this during creation of the fragment in the defsnippet but I have to detach it when I return it to you. What type of logic are you having trouble integrating into a defsnippet. Can you give me more examples this logic. Below is an example of bundling the logic you show in your code example. (em/deftemplate sn "..." [id]
["_TMP_ID"] (em/set-attr :id id)) or (em/deftemplate sn "..." [id class]
[class] (em/set-attr :id id)) |
I'm trying to use some rich control structures, like this (pseudocode):
|
@tonsky, (defn my-cust-trans [id]
(em/trans [node]
(let [style (f ...)
smth (g ...)]
(if (and x y)
(at node (em/set-attr :id id))
(at node
[".class"] (em/...)
["#id"] (em/....))
node))))
(em/deftemplate sn "..." [id]
["#TOP_LEVEL_ID"] (my-cust-trans id)) |
@ckirkendall Thanks for advise, this will work great! BTW, may be this may help: if you wrap I've run quick test in webkit and it seems working for me:
Maybe this is the way to go? |
@tonsky This is the method I use to allow you to manipulate the snippet during creation. I have to detach it to make sure what I hand back is the snippet and only the snippet. Another step you have to do to get all the methods is to attach it to the live dom. I do this also during creation. |
I don't know if it's intentional or could be fixed maybe?
The problem is — I want to use compiled snippets, but I cannot put much logic inside
defsnippet
(let
definitions etc). So I'm trying to modify snippet after I materialized it, using regularat
form inside afun
.Looks like it's because it tries to call
root.getElementsByTagName(query.getTag())
atDocumentFragment
.Maybe there's another way to do this, a workaround?
Thanks.
The text was updated successfully, but these errors were encountered: