views:

219

answers:

2

I'd like my program to output the following HTML:

<!--[if lt IE 8]><link rel="stylesheet" href="../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->

Is there a way to output html comment literals with Hiccup?

+1  A: 

You got me curious, so I re-read the code: there's no explicit comment function - you would have to pass that as a string literal. But you could do something like:

(defn comment
  "Wrap the supplied HTML in a comment"
  [html]
  (str "<!--" html "-->"))

if you really needed the function (although that's pretty simplistic). You could always add the IE if statement as an optional parameter.

Will
+4  A: 

Just insert them. Maybe this is a little bit cheating, but it works...

user=> (html
         [:html
          [:head
           "<!--[if lt IE 8]>"
           [:link {:rel  "stylesheet"
                   :href "../blueprint/ie.css"
                   :type "text/css"
                   :media "screen,projection"}]
           "<![endif]-->"]])
<html><head><!--[if lt IE 8]><link href=\"../blueprint/ie.css\" media=\"screen,projection\" rel=\"stylesheet\" type=\"text/css\" /><![endif]--></head></html>
kotarak