Compojure/HiccupでHTMLコメントを出力するにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/2905321

  •  04-10-2019
  •  | 
  •  

質問

私のプログラムに次のHTMLを出力したいです。

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

しゃっくりで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ステートメントをオプションのパラメーターとしていつでも追加できます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top