Version 4, last updated by at June 15, 2010 14:53 UTC
Setting the DocType
Lift currently defaults to the XHTML 1.0 Transitional DocType for all generated pages. If you’re producing content in another version of HTML, you’ll want to set the appropriate DocType. You can do this persistently (for every request to your Lift application), or on a page-by-page basis.
Persistently setting the DocType
To set a custom DocType persistently, place the following in your Boot.scala (most likely located in src/main/scala/bootstrap/liftweb/), in the Boot class:
// set DocType to HTML5
LiftRules.docType.default.set((r: Req) => r match {
case _ if S.skipDocType => Empty
case _ if S.getDocType._1 => S.getDocType._2
case _ => Full(DocType.html5)
})
The available DocType options, as declared in the net.liftweb.http.DocType object, are:
- xhtmlTransitional
- xhtmlStrict
- xhtmlFrameset
- xhtml11
- xhtmlMobile
- html5
Use any of the above in place of html5 in the code example above.
Setting the DocType for a given page
In the body of your method, include a variation of the following:
// set DocType for this response to HTML5 S.setDocType(Full(DocType.html5))
The S object represents the current HTTP request and response.