Skip to content
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

Defmethod compile-element ::literal-tag-and-hinted-attributes #118

Merged
merged 2 commits into from
Apr 26, 2016

Conversation

ajchemist
Copy link
Contributor

@ajchemist ajchemist commented Apr 25, 2016

I think sablono can avoid some redundant type checking code with simple metadata hint, at runtime.

Here is some examples of rum component that its first arg attrs is always expected to be attribute data in cljs context.

(macroexpand-1
 '(rum/defc button < rum/static
    [& [attrs content]]
    [:button.mdl-button.mdl-js-button attrs content])) ; no ^:attrs hint
(def button "" (clojure.core/let [render-mixin__4606__auto__ (rum.core/render->mixin (clojure.core/fn ([& [attrs content]] (do (clojure.core/let [attrs50227 attrs] (clojure.core/apply js/React.createElement "button" (if (clojure.core/map? attrs50227) (sablono.interpreter/attributes (sablono.normalize/merge-with-class {:class ["mdl-button" "mdl-js-button"]} attrs50227)) #js {:className "mdl-button mdl-js-button"}) (if (clojure.core/map? attrs50227) [(sablono.interpreter/interpret content)] [(sablono.interpreter/interpret attrs50227) (sablono.interpreter/interpret content)]))))))) class__4607__auto__ (rum.core/build-class (clojure.core/concat [render-mixin__4606__auto__] [rum/static]) "button") ctor__4608__auto__ (clojure.core/fn [& args__4609__auto__] (clojure.core/let [state__4610__auto__ (rum.core/args->state args__4609__auto__)] (rum.core/element class__4607__auto__ state__4610__auto__ nil)))] (clojure.core/with-meta ctor__4608__auto__ {:rum/class class__4607__auto__})))
(macroexpand-1
 '(rum/defc button < rum/static
    [& [attrs content]]
    [:button.mdl-button.mdl-js-button ^:attrs attrs content])) ; ^:attrs hint
(def button "" (clojure.core/let [render-mixin__4606__auto__ (rum.core/render->mixin (clojure.core/fn ([& [attrs content]] (do (clojure.core/let [attrs50223 attrs] (clojure.core/apply js/React.createElement "button" (sablono.interpreter/attributes (sablono.normalize/merge-with-class {:class ["mdl-button" "mdl-js-button"]} attrs50223)) [(sablono.interpreter/interpret content)])))))) class__4607__auto__ (rum.core/build-class (clojure.core/concat [render-mixin__4606__auto__] [rum/static]) "button") ctor__4608__auto__ (clojure.core/fn [& args__4609__auto__] (clojure.core/let [state__4610__auto__ (rum.core/args->state args__4609__auto__)] (rum.core/element class__4607__auto__ state__4610__auto__ nil)))] (clojure.core/with-meta ctor__4608__auto__ {:rum/class class__4607__auto__})))

@r0man
Copy link
Owner

r0man commented Apr 25, 2016

@ajchemist Could you please add some tests, then I would merge this?

@ajchemist
Copy link
Contributor Author

@r0man sure. I've added some tests.

@r0man r0man merged commit 8f22b0a into r0man:master Apr 26, 2016
@r0man
Copy link
Owner

r0man commented Apr 26, 2016

@ajchemist Released as 0.7.1. Thanks!

ajchemist added a commit to ajchemist/rum that referenced this pull request Apr 26, 2016
tonsky pushed a commit to tonsky/rum that referenced this pull request Apr 26, 2016
* Update sablono

r0man/sablono#118

* Respect existing arglists metadata in rum/def* macros

Here is a example about this

https://github.com/aJchemist/rum-mdl/blob/master/src/rum/mdl.cljc#L184
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants