Fork me on GitHub
#reagent
<
2020-10-11
>
teodorlu21:10:10

Is :ul#mytag.myclass a valid tag, but :ul.myclass#mytag not? Is there a reason for this?

p-himik21:10:15

Reagent is based on Weavejester's Hiccup. This is the relevant line in the original code: https://github.com/weavejester/hiccup/blob/master/src/hiccup/compiler.clj#L61

p-himik21:10:05

Thinking about it now, I would probably implement it the same way (although I try not to use this sugar myself). Much easier to parse and a bit easier to read Hiccup that adheres to a single cohesive style.

teodorlu22:10:30

Gotcha. Thanks!

teodorlu22:10:39

That's one dense regexp.

teodorlu22:10:09

> although I try not to use this sugar myself You'd write it as [:ul {:class "myclass" :id "mytag"}]? The visual separation does make it a bit easier on the eyes.

p-himik22:10:15

If you replace strings with keywords it becomes even better. Especially if your development environment highlights usages of the same keyword and can search for them across multiple files. It also makes it possible to have conditional classes and IDs while maintaining the same style across the whole codebase.

p-himik22:10:52

BTW in Reagent, you can go nuts with classes:

[:div {:class [:a :b (when add-c? :c)]} ...]

👍 3
teodorlu22:10:55

> replace strings with keywords Huh, I like that. It's almost like you can refactor CSS!

teodorlu22:10:08

I gotta get some sleep. Thanks for your advice!

👍 3