Not to distract from the talk on how to achieve these things in Clojure but I really want to second Stuart's recommendation of StringTemplate, it really is a great library and is seamless to use from Clojure.
I would recommend it for any templating needs, not just HTML views, in fact I have used it at a micro level in Java to do just the kind of lazy binding you are talking about, passed a template as a String argument to a method and let the method then provide the attributes to be bound to the template worked great. Cheers, James Sofra On Sep 3, 11:23 pm, Stuart Sierra <the.stuart.sie...@gmail.com> wrote: > Check outwww.stringtemplate.org, a Java template library with a > functional design. > -SS > > On Sep 3, 8:42 am, ngocdaothanh <ngocdaoth...@gmail.com> wrote: > > > Hi, > > > In Rails you can create a view like this: > > > my_view.erb: > > <%= "hello" + @name %> > > > I'm new to Clojure. I want to create something like the above like > > this: > > > (defn my-view [] > > (str "hello" name)) > > > The point is: > > * name is not known when my-view is defined > > * I don't want to pass name as a argument of my-view, this is kind of > > ugly boilerplate > > > How can I implement this feature in Clojure? > > > Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---