Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Scalate in Play 1.2.3
package controllers {
import play._
import play.mvc._
object Scalate {
import java.io._
import org.fusesource.scalate._
import org.fusesource.scalate.util._
lazy val scalateEngine = {
val engine = new TemplateEngine
engine.resourceLoader = new FileResourceLoader(Some(Play.getFile("/app/views")))
engine.classpath = Play.getFile("/tmp/classes").getAbsolutePath
engine.workingDirectory = Play.getFile("tmp")
engine.combinedClassPath = true
engine.classLoader = Play.classloader
engine
}
case class Template(name:String) {
def render(args:(Symbol,Any)*) = {
scalateEngine.layout(name, args.map {case (k,v) => k.name -> v} toMap)
}
}
def apply(template:String) = Template(template)
}
object Application extends Controller {
import views.Application._
def index = {
Scalate("yop.jade").render('user -> model.User("Guillaume"))
}
}
}
package model {
case class User(name:String)
}
-@ var user: model.User
p Hi #{user.name},
- for(i <- 1 to 3)
p= i
p See, I can count!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.