如何在 Compojure/Hiccup 中输出 HTML 注释?

发布于 2024-09-03 01:50:46 字数 256 浏览 6 评论 0原文

我希望我的程序输出以下 HTML:

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

Is there a way tooutput html comment Lites with Hiccup?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

断念 2024-09-10 01:50:46

只需插入它们即可。也许这有点作弊,但它确实有效......

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>

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>
允世 2024-09-10 01:50:46

你让我很好奇,所以我重新阅读了代码:没有明确的注释函数 - 你必须将其作为字符串文字传递。但是您可以这样做:

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

如果您确实需要该功能(尽管这非常简单)。您始终可以添加 IE if 语句作为可选参数。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文