How to incorporate html5shiv

269 views
Skip to first unread message

Stevo

unread,
Dec 31, 2010, 8:05:38 PM12/31/10
to Lift
In trying to make HTML5 work in IE, I decided to integrate the
html5shiv library into my default.html file. When I place this:

<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></
script>
<![endif]-->

in that file's header though, it does not become part of the page
source. Does anyone know what might be causing this to happen?

Best regards and Happy New Year,


Steve
--

Timothy Perrett

unread,
Jan 1, 2011, 8:04:50 AM1/1/11
to Lift
You'll need to add:

LiftRules.stripComments.default.set(() => false)

to your Boot class. By default, Lift strips comments.

Cheers, Tim

David Pollak

unread,
Jan 1, 2011, 8:07:28 AM1/1/11
to lif...@googlegroups.com
On Fri, Dec 31, 2010 at 5:05 PM, Stevo <thomps...@gmail.com> wrote:
In trying to make HTML5 work in IE, I decided to integrate the
html5shiv library into my default.html file.  When I place this:

<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></
script>
<![endif]-->

in that file's header though, it does not become part of the page
source.  Does anyone know what might be causing this to happen?

In general, if you want to include the funky IE comments, it's best to do it in a snippet:

import scala.xml._

object InsertHtml5Shiv {
  def render = Unparsed(

"""<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></ script>
<![endif]-->
""")

}

That'll force the bytes (well, characters) just as you've written them into the output (make sure they are correct).
 

Best regards and Happy New Year,


Steve
--

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

Antonio Salazar Cardozo

unread,
May 26, 2011, 11:31:00 AM5/26/11
to lif...@googlegroups.com
We use a snippet that stands in for the comment tags themselves:

  object Util {
    def snippetHandlers : SnippetPF = {
      case List("ie-conditional-comment") => ieConditionalComment _
    }

    def ieConditionalComment(xhtml:NodeSeq) = {
      val ieVersion =
        (for (version <- S.attr("version")) yield version) openOr "IE"
      Unparsed("<!--[if " + ieVersion + "]>") ++ xhtml ++ Unparsed("<![endif]-->")
    }
  }

(Util.snippetHandlers gets added to LiftRules.snippets.)

Then you can do:

<lift:ie-conditional-comment>
  <stuff>
</lift:ie-conditional-comment>

You can also do:

<lift:ie-conditional-comment version="IE9">
  ...
</lift:ie-conditional-comment>

If you use lift:with-resource-id inside (which we do), you'll also need to add eager_eval="true" to the end.
Thanks,
Antonio
Reply all
Reply to author
Forward
0 new messages