Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/). | ||
|