Comments (9)
Not sure you can use meta like this with a macro but a map instead of key word for options I think is a brilliant idea. It gives us a syntax that is expandable without having to change the basic structure.
from enfocus.
Turns out you actually can use metadata in macros calls:
user=> (defmacro deftemplate [name & _] (pr-str (meta name)))
#'user/deftemplate
user=> (macroexpand-1 '(deftemplate ^:private foo))
"{:private true}"
from enfocus.
Were you doing this in a clojurescript repl? If not can you try it in a clojurescript repl. Not all the information you normally get in clojure is passed by the clojurescript compiler during macro expansion. If we can do this that would be great. If the clojurescript repl does not work, I can work on adding to the clojurescript compiler. I already have to add sending the namespace of symbols.
from enfocus.
Nope, that was a Clojure repl, here's a ClojureScript example:
;; macros.clj
(defmacro deftemplate [name & _]
`(.log js/console (pr-str ~(meta name))))
;; test.cljs
(deftemplate ^:private foo)
When I try this, I see {:private true}
in the browser console, so I guess it's possible in the ClojureScript as well.
from enfocus.
That is great, I like this a lot better than the :compile :remote setup we
had.
CK
On Thu, Jun 7, 2012 at 4:39 PM, Sergei Lebedev <
[email protected]
wrote:
Nope, that was a Clojure repl, here's a ClojureScript example:
;; macros.clj (defmacro deftemplate [name & _] `(.log js/console (pr-str ~(meta name)))) ;; test.cljs (deftemplate ^:private foo)When I try this, I see
{:private true}
in the browser console, so I
guess it's possible in the ClojureScript as well.
Reply to this email directly or view it on GitHub:
#13 (comment)
from enfocus.
The more I think about this the more I love it! Its clean, doesn't affect the syntax of the macro and can be extended easily. If I get some time this weekend I will take a crack at this, unless you are already implementing something.
from enfocus.
One more thing we need to decide on: do we allow passing metadata to the generated functions, or is it enfocus-only? :private
is a good example of this.
from enfocus.
I've created a feature/metadata branch in my fork.
from enfocus.
@superbobry I noticed in your branch you have the location as part of the meta data. I would like to keep the syntax as consistent as possible. The location is a required part and should remain as part of the normal syntax where as private and compiled are optional inputs best left in the meta data. What you got so far looks great, I am thinking about moving towards 1.0 release and would love to have this be part the first release. I have finished up quite a bit of the Domina migration and If you want to concentrate on this I can take a look at the event stuff. Thanks again for helping out with Enfocus it is very appreciated!
CK
from enfocus.
Related Issues (20)
- Need escape content in ef/content or make other function that do correct html escaping.
- transform object DocumentFragment to string HOT 5
- event handler functions within hiccup-html HOT 2
- replace-vars broken in clojurescript 1.7.145 HOT 6
- Great project
- Extractor extract node HOT 1
- Clone-for and lists HOT 15
- Hiccup input control - checked and disabled not working HOT 2
- Requiring enfocus.macros under Clojure 1.10 and above triggers an error
- compiling fails at target/cljsbuild-compiler-0/enfocus/core.cljs HOT 4
- get-prop doesn't work on data attributes HOT 1
- listen-live looses event information HOT 6
- Multiple Extractions HOT 5
- Add optional callback for when view-binding function completed HOT 6
- debug should be set to false by default HOT 4
- (read-form) on IE8 results in [object]is not ISeqable HOT 7
- How can I use holder.js in html snippet? HOT 4
- Difference in ef/content behaviour HOT 2
- clone-for issue "TypeError: enfocus.core.last_element_child is undefined" HOT 1
- Function based inline snippets HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enfocus.