| b | c | d
a| e | f | g
| h | i | j
| l | m | n
k| o | p | q
| r | s | t
So “a” and “k” need to have rowspan 3. I can’t seem to figure this one out. With hiccup, every function call can only return a single element so I can’t figure out how to get three rows where the first one is a different length than the rest.
Are you referring to the hiccup-like syntax in Reagent, or actual HTML rendering using the hiccup library? The single element limitation only applies to Reagent (really React).
In either case, a seq will be expanded into the children, which should support map and for expressions:
A common pattern with hiccup/reagent is to use for with (map-indexed vector coll) which gives you a seq of index/value pairs, which I destructure with [idx row]. If the index is zero, also add the rowspan element.
You’re probably familiar with the map function which takes a function as the second argument and calls it for each element and returns as a seq. The mapcat function will do the same, but if the fn returns a seq it will concat them together into a single seq. This is similar to flatMap in other languages.
The for macro and mapcat function return sequences, where hiccup will take each item and consider it a child node on the parent [:tag …] form.
If you’re familiar with Django for rendering HTML templates, you might find Selmer to your liking. It’s what we use at work for all of our server-side rendered HTML pages and our HTML emails.