Hiccup compatibility

201 views
Skip to first unread message

Saul

unread,
Aug 19, 2010, 10:25:14 AM8/19/10
to Enlive
Hello,
At the moment I am using Hiccup to generate some HTML and then using
Enlive to put the HTML in a form using the function (html-snippet my-
html).

e.g
[:input] (substitute (html-snippet
(hiccup/html [:input {:type "text" :value
"whatever"}])))

This works fine except it seems untidy to have to do:
clojure datastructure -> string -> clojure datastructure -> html page

Since Hiccup and Tagsoup are compatible and Enlive uses tagsoup. Am I
missing an easier way of doing this?

Thanks again for all your help.
Saul

Christophe Grand

unread,
Sep 1, 2010, 4:30:04 AM9/1/10
to enlive-clj
Hello,

On Thu, Aug 19, 2010 at 4:25 PM, Saul <sha...@gmail.com> wrote:
At the moment I am using Hiccup to generate some HTML and then using
Enlive to put the HTML in a form using the function (html-snippet my-
html).

e.g
[:input] (substitute (html-snippet
                    (hiccup/html [:input {:type "text" :value
"whatever"}])))

This works fine except it seems untidy to have to do:
clojure datastructure -> string -> clojure datastructure -> html page

It's indeed ineffecient.

Since Hiccup and Tagsoup are compatible and Enlive uses tagsoup. Am I
missing an easier way of doing this?

Yes and no. I don't think tagsoup is part of the picture. What you need is a hiccup-compatible fn which output a clojure.xml tree instead of a string.
Thus you would replace
clojure datastructure (hiccup) -> string -> clojure datastructure (xml) -> html page
by
clojure datastructure (hiccup) -> clojure datastructure (xml) -> html page



--
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)
Reply all
Reply to author
Forward
0 new messages