Search code examples
playframeworkplayframework-2.3twirl

Play Framework trouble importing scala template from different package


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?


Solution

  • 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")