Nico Balestra
Nico Balestra

Reputation: 266

How to add a string containing HTML with Clojure Enlive

I have defined a template in this way:

(deftemplate layout-string "path/to/html/container.html"
  [content-strings]
  [:#container :> :div.pad]  (content (html-snippet (apply str content-strings)))
)

Here content-strings contain a HTML (for example: "<tr><td><a href="mylink">my link</a></td></tr>) Unfortunately this doesn't work. Instead it's removing the <tr> and the <td> leaving only the <a> tag. I've tried with different approach (with different unsuccessful results). Any help would be very welcome!

Upvotes: 0

Views: 1262

Answers (1)

cgrand
cgrand

Reputation: 7949

html-content is the function you need. However it's bad performance-wise. Where does this html string come from?

EDIT: example

=> (sniptest "<div>"
     [:div] (html-content "<tr><td><a href=\"mylink\">my link</a></td></tr>"))
"<div><tr><td><a href=\"mylink\">my link</a></td></tr></div>"

Upvotes: 1

Related Questions