Getting lift-scalate to accept .jade files

302 views Asked by At

I am currently re-implementing some project using Lift. All the old views were done using jade for express.js, and I was glad to read that Scalate seems to be able to handle it as well.

It's not as easy as it sounds, it seems. After adding the line

(new ScalateView).register

and changing the view files, it should work, according to any source I found. But when I try to open the http://localhost:8080/, I get an error "The Requested URL / was not found on this server".

The console logs tell me they were searching the files index.ssp and index.scaml. But there is, of course, only an index.jade. I thought it could be that the version of scalate was too old, so I changed my build.sbt:

name := "project"

version := "0.0.1"

scalaVersion := "2.9.1"

seq(webSettings: _*)

libraryDependencies ++= {
  val liftVersion = "2.4-M5"
  Seq(
    "net.liftweb" %% "lift-webkit" % liftVersion % "compile->default",
    "net.liftweb" %% "lift-mongodb" % liftVersion % "compile->default",
    "net.liftweb" %% "lift-mongodb-record" % liftVersion % "compile->default",
    "net.liftweb" %% "lift-wizard" % liftVersion % "compile->default",
    "net.liftweb" %% "lift-scalate" % liftVersion % "compile->default",
    "org.fusesource.scalate" % "scalate-core" % "1.5.3" % "compile->default"
  )
}

libraryDependencies ++= Seq(
  "junit" % "junit" % "4.5" % "test->default",
  "org.eclipse.jetty" % "jetty-webapp" % "8.0.4.v20111024" % "container",
  "javax.servlet" % "servlet-api" % "2.5" % "provided->default",
  "ch.qos.logback" % "logback-classic" % "0.9.26" % "compile->default"
)

But it's still the same problem.

What is the undocumented magic trick to get this working?

1

There are 1 answers

0
sfduhifze On BEST ANSWER

It's because the Lift Scalate plugin doesn't support .jade files by default

I had to create my own ScalateView.scala and LiftTemplateEngine.scala and add them to my project tree in src/main/scala/code/lib/

Moreover there is a bug somewhere between scalate and Lift wich make it fail with scala 2.9.0+. I had to use scala 2.8.0 to get it work

The two files :

http://pastebin.com/mLU0DAFu

http://pastebin.com/AmJmBjE7

Be sure to import code.lib.ScalateView in your Boot.scala file