[中文]
2012-08-05 20:03 墳墓 (Brian Hsu) Using XHTML5 in Lift
Lift's template system already provides modes of XHTML and HTML5. But I would like to make Lift output XHTML5. So I could use HTML5 features like placeholder attribute, but still has a well-formed XHTML document.
It turns out it's quite easy to do this in Lift. Just using the following code in bootstrap class and we will have XHTML5 output.
import net.liftweb.http.Req
import net.liftweb.http.Html5Properties
import net.liftweb.http.OldHtmlProperties
import net.liftweb.http.XHtmlInHtml5OutProperties
class Boot {
def boot
{
// ....
LiftRules.htmlProperties.default.set { r: Req =>
val xhtml = new OldHtmlProperties(r.userAgent)
val html5 = new XHtmlInHtml5OutProperties(r.userAgent)
html5.setHtmlWriter(xhtml.htmlWriter)
}
}
}
回響