As a concrete example, a small hobby project I did resulted in a fairly comprehensive library of Bootstrap helpers with very little effort:
* https://github.com/asmala/giddyup
I don't have much experience with Enlive but I find the approach is intriguing. On paper it seems perfect for clean separation of markup and logic, but you're right that careless use of the library leads to tight coupling due to the selector naming. I wonder if it would be possible to circumvent this issue using custom HTML attributes or even pseudo-CFML custom tags to indicate logical units in HTML?
<!-- Original -->
<span class="username">joe</span>
<!-- New -->
<span class="username"><strong>joe</strong></span>
Updating the selector in the template is easy enough but seems a bit tedious if the design team decides to go for italics next week. Another option would be adding another CSS class or a data attribute to indicate which element should wrap username.How do you usually handle such scenarios?
Anyway if you really want to program defensively against such changes, roll your own replacement to content fn which would replace the cornets not of the current node but of all its terminal descendants.
I'd like to know more about your workflow.
a) "Don't touch the markup without an explicit agreement between the two of us."
b) "Please make sure you have an element with a data-content-for='user.username' somewhere in the HTML."
Sometimes the design is forced upon the team (eg corporate intranet) and then one has to resort to ugly and brittle selectors but still I prefer that to slicing and dicing the design to add loops and conditionals – especially when the intranet's corporate branding change every 9 months :-/
(Thanks for rewording your reply)
They're all built with with the presumption that the person doing the frontend work (HTML, CSS, JS) will also be doing the backend (Clojure, database) coding.
This is almost never the case in my line of work.
Hiccup violates this principle by embedding the html in my Clojure and Enlive couples markup with data tightly in ways that horrify me.
The only approach I've seen that could work for more serious projects is using stencil because then the map of data you pass to the template-side is a 'contract' of sorts, but they can work with the data you pass however it works for them.
That's somewhat regrettable as I prefer Jinja-style templating to mustache, but Stencil (mustache) is the only viable alternative I've found.
I cannot possibly be the only person with a keen interest in Clojure who hasn't abandoned division of labor.