weavejester/hiccup

Add possibility to set CSS classes using vector

vincent-dm opened this issue · 3 comments

CSS classes are often conditional, based on some application logic.

Currently, it seems like you need to concatenate the :css string manually.

I tried passing a vector of CSS classes, but unfortunately they are concatenated using commas instead of spaces.

If this concatenation would happen with spaces, it would be an elegant way to assemble classes.

For example:

[div {:css ["label" (if selected "label-primary" "label-default")]} "Lorem ipsum"]

I would love this as well. I'm training myself on Clojure having come from JavaScript, which has the very handle element.classList, which returns element's current classes as a JS array. Then there are the related classList.add, classList.remove, and classList.toggle` methods, which are superduper for doing logic-based application of classes.

Something like those in Hiccup & Clojure vectors would be amazing.

#139 seems also added this feature.

Fixed by #139.