garden icon indicating copy to clipboard operation
garden copied to clipboard

arithmetics does not compile in clojurescript

Open gfrivolt opened this issue 8 years ago • 5 comments

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.

gfrivolt avatar Nov 29 '15 22:11 gfrivolt

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.

jeluard avatar Dec 04 '15 09:12 jeluard

@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?

noprompt avatar Dec 06 '15 18:12 noprompt

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 avatar Dec 07 '15 03:12 jeluard

@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

gfrivolt avatar Dec 07 '15 16:12 gfrivolt

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.

noprompt avatar Oct 28 '16 17:10 noprompt