views:

1059

answers:

1
+4  A: 

From what I've read about Compojure, I don't think it has inherent support for the concept of "auto prepend" and "auto append" to the response body like PHP does.

Other web frameworks with which I have experience delegate this responsibility to their templating engine, whereas PHP sort of blurs the lines a bit. They do this by allowing you to explicitly "include" a common snippet here, or render a macro, or even through rudimentary forms of inheritance (this template extends that template).

Basically, whether your HTML is static or dynamic, a templating engine allows you to modularize for better maintainability.

That said, Compojure doesn't appear to have a full-blown HTML templating engine bundled with it. It does have a nice little HTML/XML domain-specific language (DSL), but I think what you are looking for is more of a first class templating engine that can be used along with Compojure.

Enlive seems to be the Clojure-inspired templating engine that get the most hits, but I'm sure there are others. Given Clojure's JVM integration, you can probably pick from any of the Java-inspired templating engines as well.

Depending on which one you pick, there may be a few lines of glue code that you have to write to get your templates loaded, rendered and streamed into the Compojure HTTP responses, but you will write that once and reuse everywhere.

Joe Holloway