我希望我的程序输出以下HTML:
<!--[if lt IE 8]><link rel="stylesheet" href="../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->有没有办法用Hiccup输出html注释文字?
发布于 2010-05-25 22:40:36
只需插入它们。也许这有点欺骗,但它是有效的。
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>发布于 2010-05-25 22:33:19
您引起了我的好奇心,所以我重新阅读了代码:没有显式的注释函数-您必须将其作为字符串文字传递。但是你可以这样做:
(defn comment
"Wrap the supplied HTML in a comment"
[html]
(str "<!--" html "-->"))如果你真的需要这个函数(尽管这太简单了)。您始终可以将IE if语句添加为可选参数。
https://stackoverflow.com/questions/2905321
复制相似问题