Skip to content

Instantly share code, notes, and snippets.

@guillaumebort
guillaumebort / gist:1207364
Created September 9, 2011 21:18
Compiling Play 2.0 type safe templates
val ScalaTemplates = (sourceDirectory:File, generatedDir:File, templateTypes:Function1[String,(String,String)], additionalImports:String) => {
import play.templates._
(generatedDir ** "*.template.scala").get.map(GeneratedSource(_)).foreach(_.sync())
try {
(sourceDirectory ** "*.scala.html").get.foreach { template =>
ScalaTemplateCompiler.compile(template, sourceDirectory, generatedDir, templateTypes("html")._1, templateTypes("html")._2, additionalImports)
}
} catch {
case TemplateCompilationError(source, message, line, column) => {