Search code examples
twitter-bootstraphaskellcommentsblaze-html

How can I embed <!--[if lt IE 9]> tags into Blaze.Html5-generated HTML?


I'm trying to output the minimal template for Twitter Bootstrap using the Text.Blaze.Html5 module, but it has comments like the following which I don't know how to include in the Blaze output (I can't see any 'comment' functions in Text.Blaze.Html5):

<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->

(from http://getbootstrap.com/getting-started/#template)

How should I go about generating such code?

The docs here http://jaspervdj.be/blaze/docs/Text-Blaze-Html5.html don't provide any clues.


Solution

  • You can use preEscapedText from Text.Blaze.Internal. Here is an example, adapted from the starter kit:

    import Text.Blaze.Html5 (docTypeHtml)
    import Views.Utils (pet) -- `pet` is an alias for `preEscapedText`
    
    layout t b = docTypeHtml $ do
           pet "<!--[if lt IE 7]> <html class='no-js lt-ie9 lt-ie8 lt-ie7'> <![endif]-->"
           pet "<!--[if IE 7]> <html class='no-js lt-ie9 lt-ie8'/> <![endif]-->"
           pet "<!--[if IE 8]> <html class='no-js lt-ie9'> <![endif]-->"
           pet "<!--[if gt IE 8]><!--> <html class='no-js'> <!--<![endif]-->"