我希望我的程序输出以下 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 if 语句添加为可选参数。