2 ms·
Clojure is powerful enough that its easy to write a "true" templating library along the lines you describe. I wrote a very simple templating tool (47 loc) that
by papaf 17y ago
Clojure is powerful enough that its easy to write a "true" templating library along the lines you describe. I wrote a very simple templating tool (47 loc) that allowed clojure to be evaluated within PHP style tags -- I didn't use it because I felt it doesn't add anything other than familiarity i.e. it was a step backwards.
If you write your own html then compojure is, without question, the way to go. S-expressions require less typing than html and you can write functions or define snippets that build webpages up without the need to repeat yourself. Its an end to copy and paste. Also, stylesheets are your friend and can do most of the work of presentation.
If you work with designers who require full access to the HTML then Enlive is a good option -- as you said there is no template code in with the html! Surely this is a step forwards from custom comment fields or custom tags?
- icey 17y agoRolling your own templating library would certainly work, but then you're stuck maintaining your own templating library. I like the concept of Enlive, but I have concerns about troubleshooting it. I feel like you're asking for trouble any time you have to look at multiple files just to figure out what's going on in one page. Troubleshooting a page that's been modified with Enlive would require you to have the HTML open, and then mentally translate all the operations so that you can see what changes what. I'm just not smart enough to be able to hold entire documents in my head when things approach even moderate complexity, and I want to be able to scan a document to see what's going on; not read the HTML document and then go through the list of operations to see how that document is being modified.