我希望我的程序输出以下HTML:
<!--[if lt IE 8]><link rel="stylesheet" href="../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
有没有办法在Hiccup中输出HTML注释?只需将它们插入即可。也许这有点作弊,但它能起作用...
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>
你让我很好奇,所以我重新读了代码:没有明确的注释功能 - 你必须将其作为字符串文字传递。但你可以这样做:
(defn comment
"Wrap the supplied HTML in a comment"
[html]
(str "<!--" html "-->"))
如果你确实需要该函数(尽管这相当简单),你可以将IE条件语句作为可选参数添加。