3 ms·
A bit off topic, but I don't understand why Hiccup is so commonly used in the clojure community. It seems like a step backward from other templating libraries.
by dmix 15y ago
A bit off topic, but I don't understand why Hiccup is so commonly used in the clojure community.
It seems like a step backward from other templating libraries... to build HTML layouts using the programming language.
Designers always mock up layouts in HTML first then integration is as simple as replacing mock content with variables/partials/etc. It would be a lot of extra work to translate that into Hiccups Clojure code.
Why not just use something like Enlive, where you can keep standard HTML and still keep the logic out of the views?
- technomancy 15y agoI suspect most Clojure web apps are built by smaller teams where the HTML is written by the same developers as the rest of the codebase. Enlive also has a reputation for using confusing macros and having poor documentation. I've been told it's improved a lot, but it's hard to shake an impression like that sometimes. For better or worse, Hiccup is absolutely _obvious_, and that counts for a lot.
- wink 15y agoMuch more than that I've come to love that fact that it's Clojure and I can iterate over lists for example. It's not spaghetti html wrapped inside $language, it's useful and you can work with it.
- icey 15y agoThis is exactly why I prefer hiccup. I can operate on my interface code using the full power of the language, and it looks just like everything else in my project. That's not to say Enlive isn't capable as well, but when I'm working on my own using Hiccup means one fewer context-switch when thinking about what I'm building.
- weavejester 15y agoI think it rather depends on how homogeneous you plan on making the user interface to your web application. The more repetition in the design, the more you benefit from being able to factor it out into smaller components, and functions are obviously more suited to this than partials. So if you're writing a web application with a small number of unique views that have been carefully constructed by a dedicated designer, then maybe Enlive is the better choice. But if you're designing a web application with many views that tend to share a lot of common traits, then by factoring out common UI elements into functions, you can often end up with a far smaller and cleaner view definition.