On Mar 29, 3:13 pm, B Smith-Mannschott <bsmith.o...@gmail.com> wrote: > I can see the advantages of going this route for simple templates that > contain no optional elements and no repetition, but that's not going > to get me far. I still don't understand how these kinds of issues: > > (defn constructor > [{:keys [class-name fields] :as cfg}] > [" " class-name "(" (formal-params cfg) ") {\n" > (statement-list > (for [f fields] > [" this." f " = " f ])) > " }\n"]) > > ... are handled in the usual templating solutions without needing a > turing complete templating language. But, at that point, I'm not sure > what I've gained, as I already have a perfectly servicable programming > language in Clojure. How does one really separate "content" from > "presentation" in such a case?
Unlike a lot of people, I personally I don't see the problem as avoiding expressiveness in the templates. I see the problem as one of context switching between generating code and the template. The Hiccup library does this nicely by allowing datastructures to be the template and clojure s-expressions to be the generating code. The cost of this is that formatting is lost - however, this is actually a feature since the minimized output is read by a browser rather than a human being. There are two additional problems when generating a algol-like programming language from within Clojure. The language itself is hard to express within clojure and the formatting is usually important. Because of this I would recommend a templating system that has been specifically written to preserve formatting. If you need loops then StringTemplate supports them. I haven't done this within Clojure but below is small example of a C++ Cheetah template: https://gist.github.com/892415 Although it looks a bit of a mess the general structure of the C++ is clear and the templating code is not too intrusive. Saul -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en