Giter Club home page Giter Club logo

Comments (10)

ckirkendall avatar ckirkendall commented on July 28, 2024

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?

from enfocus.

superbobry avatar superbobry commented on July 28, 2024

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.

from enfocus.

ckirkendall avatar ckirkendall commented on July 28, 2024

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.

from enfocus.

si14 avatar si14 commented on July 28, 2024

+1 here to @superbobry and thanks for the great lib!

from enfocus.

ckirkendall avatar ckirkendall commented on July 28, 2024

I am going to add another issue for the move to domina as a base layer for enfocus.

from enfocus.

superbobry avatar superbobry commented on July 28, 2024

Mind if I'll try to implement this myself and then submit a PR?

from enfocus.

ckirkendall avatar ckirkendall commented on July 28, 2024

That would be great!
On May 16, 2012 7:20 AM, "Sergei Lebedev" <
[email protected]>
wrote:

Mind if I try to implement this myself and then submit a PR?


Reply to this email directly or view it on GitHub:
#3 (comment)

from enfocus.

superbobry avatar superbobry commented on July 28, 2024

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?

from enfocus.

ckirkendall avatar ckirkendall commented on July 28, 2024

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)))

from enfocus.

superbobry avatar superbobry commented on July 28, 2024

Yup, this looks good, thanks :)

from enfocus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.