问题
Using Play 2.3.7, I have a set of bootstrap3 templates similar to this example project, and they are in a package app/views/bootstrap3/
. One of these bootstrap3 templates is a text field object in a file named text.scala.html
. In a separate package, I have some other templates in which I want to use my custom text field. So, in package app/views/other/
let's say I have I have a file index.scala.html
, how do I correctly import my Bootstrap3 templates? This is what I have in my code
@import views.bootstrap3._
@* my bootstrap3 text field template *@
@text("some", "params", "here")
However, when I try to compile I get an error in index.scala.html
(line 3) saying that
package scala.text is not a value
How do I fix my code so that I can import my templates from a separate package?
回答1:
Templates named something.scala.html
get compile to a views.{suffix}
package, where the suffix in this case is html
, so for the fully qualified import you need to do:
@import views.html.boostrap3._
@text("some", "params", "here")
回答2:
No need to use import in the above case. you can just use
@bootstrap3.text()
in your in index.scala.html, it will import the partial template from bootstrap3/text.scala.html
来源:https://stackoverflow.com/questions/28522438/play-framework-trouble-importing-scala-template-from-different-package