Created
December 5, 2011 17:23
-
-
Save eltimn/1434455 to your computer and use it in GitHub Desktop.
Mixing HTML5 and XML support in Lift
This file contains hidden or 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
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