Explictially Setting Application DocType with Lift

As you might know, I use the lift framework a lot - I recently came across a strange issue where I couldnt set my own doctype in the layout template. Maybe this nugget of information will be usefull for someone:

ResponseInfo.docType = { 
  case _ if S.getDocType._1 => S.getDocType._2 
  case _ => Full(DocType.xhtmlStrict) 
}

/*
Avalible options are:

xhtmlTransitional
xhtmlStrict
xhtmlFrameset
xhtml11
xhtmlMobile

*/

UPDATE (Lift 2.1)

Be sure to use the following as ResponseInfo is deprecated.

LiftRules.docType.default.set(r => Full(DocType.xhtmlStrict))

Doing so will ensure you don’t get any warnings etc during compile time.

comments powered by Disqus