Domanda

Vorrei che il mio programma per emettere il seguente codice HTML:

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

C'è un modo per l'output HTML commento letterali con il singhiozzo?

È stato utile?

Soluzione

Basta inserire loro. Forse questo è un imbroglio po ', ma funziona ...

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>

Altri suggerimenti

You got me curioso, così ho ri-leggere il codice: non c'è nessuna funzione di commento esplicito - che avrebbe dovuto passare che come un letterale stringa. Ma si potrebbe fare qualcosa di simile:

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

se davvero bisogno della funzione (anche se questo è piuttosto semplicistico). Si può sempre aggiungere l'IE if come un parametro facoltativo.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top