问题描述
使用Play 2.3.7,我有一组bootstrap3模板,类似于以下示例项目,它们位于软件包app/views/bootstrap3/
中.这些bootstrap3模板之一是名为text.scala.html
的文件中的文本字段对象.在一个单独的程序包中,我还有其他一些模板,我想在这些模板中使用自定义文本字段.因此,在软件包app/views/other/
中,假设我有一个文件index.scala.html
,如何正确导入Bootstrap3模板?这就是我的代码中的内容
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")
但是,当我尝试编译时,在index.scala.html
(第3行)中显示错误
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
如何修复代码,以便可以从单独的程序包中导入模板?
推荐答案
名为something.scala.html
的模板将编译为views.{suffix}
包,这种情况下的后缀为html
,因此对于完全限定导入,您需要执行以下操作:
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")
这篇关于Play Framework无法从其他包中导入Scala模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!