reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
teodorlu 2020-10-11T21:33:10.053300Z

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

p-himik 2020-10-11T21:47:15.053400Z

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-himik 2020-10-11T21:54:05.053700Z

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.

teodorlu 2020-10-11T22:16:30.054Z

Gotcha. Thanks!

teodorlu 2020-10-11T22:16:39.054200Z

That's one dense regexp.

teodorlu 2020-10-11T22:20:09.054400Z

> 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-himik 2020-10-11T22:25:15.054700Z

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-himik 2020-10-11T22:25:52.054900Z

BTW in Reagent, you can go nuts with classes:

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

👍 1
teodorlu 2020-10-11T22:26:55.055100Z

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

teodorlu 2020-10-11T22:28:08.055400Z

I gotta get some sleep. Thanks for your advice!

👍 1