Skip to content

Instantly share code, notes, and snippets.

@eltimn
Created December 5, 2011 17:23
Show Gist options
  • Save eltimn/1434455 to your computer and use it in GitHub Desktop.
Save eltimn/1434455 to your computer and use it in GitHub Desktop.
Mixing HTML5 and XML support in Lift
class Boot extends Loggable {
def boot {
// set the default htmlProperties
LiftRules.htmlProperties.default.set((r: Req) => new XHtmlInHtml5OutProperties(r.userAgent))
// set htmlProperties based on uri
LiftRules.earlyInStateful.append(HtmlPropertiesManager.testUri)
}
}
object HtmlPropertiesManager {
def testUri(br: Box[Req]) = br match {
case Full(r @ Req("knockout" :: Nil, _, _)) => setHtml5Props(r)
case Full(r @ Req("admin" :: "tasks" :: Nil, _, _)) => setHtml5Props(r)
case Full(r @ Req("admin" :: "logs" :: Nil, _, _)) => setHtml5Props(r)
case Full(r @ Req("flm" :: "scoreboard" :: _, _, _)) => setHtml5Props(r)
case _ =>
}
def setHtml5Props(r: Req) =
for (session <- S.session)
session.requestHtmlProperties.set(new Html5Properties(r.userAgent))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment