Created
August 13, 2012 15:42
-
-
Save epost/3342038 to your computer and use it in GitHub Desktop.
Liftweb body tag in conditional comments
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
object IESupport { | |
/** | |
* Lift strips out HTML comments, including IE conditional comments, so this is a workaround. We can't seem to do this | |
* for the 'html' tag though, due to restrictions in he HTML5 parser that Lift uses. | |
*/ | |
def bodyTag(bodyContent: NodeSeq): NodeSeq = { | |
val bodyTagOpen = Unparsed(""" | |
<!--[if lt IE 7]> <body class="home ie6 ie-lt-7 ie-lt-8 ie-lt-9"> <![endif]--> | |
<!--[if IE 7]> <body class="home ie7 ie-lt-8 ie-lt-9"> <![endif]--> | |
<!--[if IE 8]> <body class="home ie8 ie-lt-9"> <![endif]--> | |
<!--[if IE 9]> <body class="home ie9"> <![endif]--> | |
<!--[if gt IE 9]><!--> <body class="home"> <!--<![endif]--> | |
""") | |
val bodyContentSansOuterTag: NodeSeq = bodyContent.headOption map (origBody => origBody.child: NodeSeq) getOrElse <span>Expected single HTML body tag</span> | |
val bodyTagClose = Unparsed("</body>") | |
(bodyTagOpen +: bodyContentSansOuterTag) ++ bodyTagClose | |
} | |
s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment