Skip to content

Commit

Permalink
How to include HTML5 Shiv.
Browse files Browse the repository at this point in the history
  • Loading branch information
d6y committed Apr 14, 2012
1 parent 534bc83 commit 9b20066
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions docs/0200-Html/0450-shiv.md
@@ -0,0 +1,42 @@
Including HTML5 Shiv
====================

Problem
-------

You want to include HTML5 Shiv (a.k.a. HTML5 Shim) so you can use HTML5 elements with legacy IE browsers.

Solution
--------

Put the markup in a snippet and include the snippet in your page or template.

```scala
package code.snippet

import scala.xml.Unparsed

object Html5Shiv {
def render = Unparsed("""<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js">
</script><![endif]-->""")
}
```

Reference the snippet in the `<head>` of your `templates-hidden/default.html`, e.g.,:

```html
<script class="lift:Html5Shiv"></script>
```

Discussion
----------

The HTML5 parser used by Lift does not carry comments from the source through to the rendered page. If you're looking at `Unparsed` and worried, your instincts are correct, but in this case we do want unparsed XML content (the comment tag) included in the output.

See Also
--------

* [How to incorporate html5shiv](https://groups.google.com/forum/?fromgroups#!topic/liftweb/kLzcJwfIqHQ), from the mailing list.
* [html5shim Google code page](http://code.google.com/p/html5shim/).

0 comments on commit 9b20066

Please sign in to comment.