Code Monkey home page Code Monkey logo

Comments (8)

dubiousdavid avatar dubiousdavid commented on June 18, 2024

It would be nice to have defnode and defcnode as well in that file.

from dommy.

dubiousdavid avatar dubiousdavid commented on June 18, 2024

This should work:

(defmacro deftempl [name args node-form]
  `(defn ~name ~args
    (dommy.template/node ~node-form)))

(defmacro defctempl [name args node-form]
  `(defn ~name ~args
    (dommy.template-compile/node ~node-form)))

(defmacro defnode [name node-form]
  `(def ~name
     (dommy.template/node ~node-form)))

(defmacro defcnode [name node-form]
  `(def ~name
     (dommy.template-compile/node ~node-form)))

from dommy.

aria42 avatar aria42 commented on June 18, 2024

Why would you want to use deftemplate with the non-compiled (runtime) templating? Why would you not take the policy of compile as much of what you can that deftemplate does?

from dommy.

dubiousdavid avatar dubiousdavid commented on June 18, 2024

The convenience of the macro is useful for when you can use the compiled version of node, but also when you cannot. My understanding is that the compiled version cannot be used when you need looping, which is the largest case for me, since I'm doing 100% client-side templating.

On Mar 22, 2013, at 2:35 PM, Aria Haghighi [email protected] wrote:

Why would you want to use deftemplate with the non-compiled (runtime) templating? Why would you not take the policy of compile as much of what you can that deftemplate does?


Reply to this email directly or view it on GitHub.

from dommy.

aria42 avatar aria42 commented on June 18, 2024

No. deftemplate should always work and fall back to runtime when it can no
longer compile stuff (when you stop using literals); take a look the code
and see where it calls the runtime when it no longer can parse. So
deftemplate should always work regardless. Are you seeing a case where
it's not.

On Fri, Mar 22, 2013 at 11:39 AM, David Sargeant
[email protected]:

The convenience of the macro is useful for when you can use the compiled
version of node, but also when you cannot. My understanding is that the
compiled version cannot be used when you need looping, which is the largest
case for me, since I'm doing 100% client-side templating.

On Mar 22, 2013, at 2:35 PM, Aria Haghighi [email protected]
wrote:

Why would you want to use deftemplate with the non-compiled (runtime)
templating? Why would you not take the policy of compile as much of what
you can that deftemplate does?


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHubhttps://github.com//issues/17#issuecomment-15314279
.

website: http://aria42.com

from dommy.

dubiousdavid avatar dubiousdavid commented on June 18, 2024

I'm not sure I fully understand what you are saying. The bottom line I believe is that the macro does not reference a specific version of node, and is not fully qualified, so the ambiguity is a problem if you want to use both versions of node.

On Mar 22, 2013, at 2:50 PM, Aria Haghighi [email protected] wrote:

No. deftemplate should always work and fall back to runtime when it can no
longer compile stuff (when you stop using literals); take a look the code
and see where it calls the runtime when it no longer can parse. So
deftemplate should always work regardless. Are you seeing a case where
it's not.

On Fri, Mar 22, 2013 at 11:39 AM, David Sargeant
[email protected]:

The convenience of the macro is useful for when you can use the compiled
version of node, but also when you cannot. My understanding is that the
compiled version cannot be used when you need looping, which is the largest
case for me, since I'm doing 100% client-side templating.

On Mar 22, 2013, at 2:35 PM, Aria Haghighi [email protected]
wrote:

Why would you want to use deftemplate with the non-compiled (runtime)
templating? Why would you not take the policy of compile as much of what
you can that deftemplate does?


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHubhttps://github.com//issues/17#issuecomment-15314279
.

website: http://aria42.com

Reply to this email directly or view it on GitHub.

from dommy.

aria42 avatar aria42 commented on June 18, 2024

But why would you want to use both versions since the macro-variant will fallback to the runtime node (dommy.core/node) when the expression isn't compile-time parseable. Why wouldn't you prefer macro-compile when possible?

from dommy.

dubiousdavid avatar dubiousdavid commented on June 18, 2024

I didn't know that it worked that way. That sounds like a good solution as far as I understand things.

On Mar 24, 2013, at 5:54 PM, Aria Haghighi [email protected] wrote:

But why would you want to use both versions since the macro-variant will fallback to the runtime node (dommy.core/node) when the expression isn't compile-time parseable. Why wouldn't you prefer macro-compile when possible?


Reply to this email directly or view it on GitHub.

from dommy.

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.