garden
garden copied to clipboard
arithmetics does not compile in clojurescript
I'm trying to compile styles in clojurescript. Artithmetics and at-import
do not compile correctly. This is a mini example of the behavior:
cljs.user=> (require '[garden.units :refer [px em]])
cljs.user=> (require '[garden.core :refer [css]])
cljs.user=> (require '[garden.arithmetic :refer [+ - *]])
cljs.user=> (css [:#el { :margin-top (+ (px 5) (px 6)) }])
"#el {\n margin-top: [object Object][object Object];\n}"
How can I get correct compilation? Thanks for help.
The issue is the default +
is still used. I suspect this is a limitation of the node repl.
If you try (css [:#el { :margin-top (garden.arithmetic/+ (px 5) (px 6)) }])
it should be fine.
@fifigyuri Could you expand on your example by show what (type (-> ?x first :margin-top))
produces where ?x
is [:#el { :margin-top (+ (px 5) (px 6)) }]
?
@jeluard Have you confirmed that the problem is the Node REPL?
No I didn't look further. Using full namespace gives the proper result so I don't think it is a issue with garden
.
@jeluard, using garden.arithmetic/+
helps. I can use it.
@noprompt:
cljs.user=> (type (-> [:#el { :margin-top (+ (px 5) (px 6)) }] first :margin-top))
nil
cljs.user=> (type (-> [:#el { :margin-top (garden.arithmetic/+ (px 5) (px 6)) }] first :margin-top))
nil
I would suggest avoiding the garden.arithmetic
library; it's going to be removed soon. See the information on the Changelog for the upcoming release.