Hi Adrian! Thanks for this tutorial, I put it on the wiki http://wiki.github.com/cgrand/enlive/getting-started (I fixed two typos: a missing paren and an extraneous colon and I simplified to-li).
Speaking of to-li, (to-li ["one" "two"]) can be written (map (wrap :li) ["one" "two"]). While trying to write a tutorial myself, I realized that this kind of simple thing (replicating a simple element) was harder than replicating a complex element: (def simple (-> "<ul><li>Sample text</li></ul>" java.io.StringReader. html-resource first)) (def harder (-> "<ul><li><a href=''>Author</a>: <blockquote>a quote</blockquote></li></ul>" java.io.StringReader. html-resource first)) (at simple [:li] #(for [x items] ((content x) %)) (at harder [:li] #(for [{:keys [link author quote]} items] (at % [:blockquote] (content quote) [:a] (do-> (set-attr :href link) (content author))))) I think I'll add a 'clone (or 'clone-for or a better name?) macro: (at simple [:li] (clone [x items] (content x))) (at harder [:li] (clone [{:keys [link author quote]} items] [:blockquote] (content quote) [:a] (do-> (set-attr :href link) (content author)))) Thanks again Adrian! Christophe Adrian Cuthbertson a écrit : > I've uploaded a file > http://groups.google.co.za/group/clojure/web/enlive-tut1.txt?hl=en > which is a basic tutorial on getting started with Enlive (the html > transformation library). > > Christophe, this is intended as a contribution to the Enlive project, > so you're welcome to use it as part of the Enlive documentation, on > the wiki, etc. Also, please feel free to enhance it and make any > corrections. > > Enlive is an outstanding tool for web development. Thanks Christophe > for your initiatives. > > Regards, Adrian. > > > > > -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) --~--~---------~--~----~------------~-------~--~----~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---