Closed superbobry closed 12 years ago
I completely agree. I been thinking about this for a while now. Part of the thing I have been struggling with is how to integrate this type of template into the existing structure without introducing complexity to the syntax of deftemplate and defsnippet. I have a few ideas:
(defsnippet :compiled "...uri..." [...enlive syntax...] [..args..] ;;normal enfocus transform )
or
(defcsnippet "..uri.." [...enlive syntax...] ;; normal transform stuff )
What do you think?
I like the first option better -- it's more straightforward than the 'c' in 'def_c_snippet' which is hard to spot (at least for me :)
Also, going offtopic, have you considered using domina for DOM manipulations? some of the things defined in core.cljs
are already provided by domina
-- for example 'style-set'. I think delegating this functionality to another lib will make enfocus
both easier to maintain and use.
Thanks on the feedback and yes I am planning on using Domina as the base layer eventually. I have been working Luke on adding features to Domina so I can do that very thing. Now that Luke finished up the new event model I should be able to remove a bunch of code and replace it with Domina underpinnings.
+1 here to @superbobry and thanks for the great lib!
I am going to add another issue for the move to domina as a base layer for enfocus.
Mind if I'll try to implement this myself and then submit a PR?
That would be great! On May 16, 2012 7:20 AM, "Sergei Lebedev" < reply@reply.github.com> wrote:
Mind if I try to implement this myself and then submit a PR?
Reply to this email directly or view it on GitHub: https://github.com/ckirkendall/enfocus/issues/3#issuecomment-5738528
Okay, I got it working, but it looks like we can't make this change without breaking backward compatibility. The current implementation is:
(defmacro deftemplate [sym mode uri args & forms]
`(do
~@(case mode
:remote `(enfocus.core/load-remote-dom ~uri)
:compiled (load-local-dom uri))
(enfocus.macros/create-dom-action
~sym
#(enfocus.core/get-cached-dom ~uri)
true ~args ~@forms)))
So old deftemplate
behavior can be achieved with :remote
tag. Is there a way to have both old and new versions for a single name?
How about something more like this. It keeps backwards compatibility. Note: I just scetch this out and have not run it.
(defmacro deftemplate [sym & body]
(let [[mode [uri args & forms]] (if (= (first body) :compiled)
[:compiled (rest body)]
[:remote body])]
`(do
~@(case mode
:remote `(enfocus.core/load-remote-dom ~uri)
:compiled (load-local-dom uri))
(enfocus.macros/create-dom-action
~sym
#(enfocus.core/get-cached-dom ~uri)
true ~args ~@forms)))
Yup, this looks good, thanks :)
It would be nice if
enfocus
allowed interning local templates during compilation (similar to what one does in its sample application), instead of loading them via XHR, what do you think?