I've just pushed a template library for Clojure up onto github for public use. You can find it here:
http://github.com/rosejn/clj-libs/tree/master This library is based loosely on erb from Ruby, which is the only other template system I've used, and it allows you to insert Clojure scriptlets inside a text document. Following is a short example of how it currently works. Any thoughts, suggestions or feedback are welcome. I plan on making it easier to instantiate pages by passing a hash, or maybe a sequence of hashes, which will be successively bound for you. I'll probably add some configuration options for handling whitespace and trimming newlines too. Any other ideas or patches welcome. Cheers, Jeff ;; Here is a short example of creating an HTML template and then ;; instantiating it under a binding to generate the string output. ;; Define an HTML page template with embedded Clojure code (def *page* "<h3>Dear <%= winner %>,<h3> <p> We are pleased to inform you that you have been nominated as president of this years <%= club %> club. Great job! You will soon receive a set of important items: </p> <ul> <% (doseq [doc documents] -%> <li><%= doc %></li> <% ) -%> </ul> <p> Thanks for all your hard work. Sincerely, <%= from %> </p>") ;; Need these or binding complains... (def winner nil) (def club nil) (def documents nil) (def from nil) (let [page (template *page*)] ;; Now calling (page) under different bindings will produce different ;; pages. (binding [winner "Joe Bob" club "Winners" documents ["winner's check" "waiver" "member list"] from "Winners Club Headquarters"] (println (page))) --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---