Play Framework无法从其他包中导入Scala模板 [英] Play Framework trouble importing scala template from different package

查看:105
本文介绍了Play Framework无法从其他包中导入Scala模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Play 2.3.7,我有一组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模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆