I need help understanding one thing. This code generates HTML code. Fine. But how come code and declaration (web designer and developer) are separated with this. Is this a good practice? I've been reading about lisp for a long time, not in depth, but I keep stumbling similar snippets a lot. Are there any good examples out there? I am teaching myself Clojure (reading the book with the bird cover) these days.
They are not separated. This approach appeals to geeks/programmers, but is completely impractical, as I've learned the hard way in several projects.
In a practical setting you will get a set of pre-cut HTML/CSS and images. Good luck splitting that into semantic markup and styling. And good luck teaching a designer how to work with it afterwards.
Because of hard-earned experience I try very hard not to put any HTML into my code, keeping it all in templates, which are much more accessible to designers and easier to modify.
Yes, this is exactly why I stayed away from things like this, despite my love for Racket and Clojure, until someone above pointed out the Enlive library. It lets you use normal HTML files as your templates but requires no code in it (not even for loops!) Basically, you use CSS-style selectors to replace the contents of elements, giving you the full power of Clojure but without having to either put code in your templates or put HTML into your code.
I have decided to investigate the possibility to include a sub-chapter to chapter 3 to discuss Caramel for people who like enlive(me included). I didn't already do so because caramel is brand new, and I haven't had the time to try it out beyond a few simple examples.
The choice to use s-expressions was made because It makes it easier to just type code in a repl and experiment, without having to worry about dealing with templates, and also because I wanted the first example to fit in a single file.
Oh, I was addressing the Racket example and the response to it, as opposed to your book; I'm not familiar with what you are doing in the book. I am still going to look into your book, as I have no CL experience, only Racket/Clojure. But adding a sub-chapter on Caramel would be really nice!
It's not as fancy as enlive though (for example, because it's not sensitive to the structure of XML, user input isn't escaped automatically, which is quite an awkward tradeoff)