Advertisement
eallik

Untitled

Jun 23rd, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.64 KB | None | 0 0
  1. private def renderTpl(response: HttpServletResponse, tplPath: String, transformer: Transformer) = {
  2.   val doc = transformer(loadTpl(tplPath))
  3.   val html = doc.map(Html5.toString).mkString
  4.   response.setContentType("text/html; charset=utf-8")
  5.   response.getWriter.println("<!doctype html>", html)
  6. }
  7.  
  8. private def loadTpl(path: String) = {
  9.   val parserFactory = new org.ccil.cowan.tagsoup.jaxp.SAXFactoryImpl
  10.   val adapter = new scala.xml.parsing.NoBindingFactoryAdapter
  11.   val tpl = getClass.getResourceAsStream(path)
  12.   val source = new org.xml.sax.InputSource(tpl)
  13.   val parser = parserFactory.newSAXParser
  14.   adapter.loadXML(source, parser)
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement