Reputation: 5792
I'm trying to solve possibly simple problem, in my 'views' directory, in typical Play framework setup, I would like to group my templates (*.scala.html files) into groups, possibly using another folder for each group, eg. I would like to have customers folder with the following files in it:
createForm.scala.html
editForm.scala.html
list.scala.html
So far so good but when I try to access that view reference from my controller (eg. Ok(views.html.list(..))
-> Ok(views.customers.html.list(...)
), I get an error:
object customers is not a member of package views
Is there any best practice/receipe on how to work with multiple views, how to gather them into groups and then how to use them in other views or controllers.
Thx in advance.
Upvotes: 5
Views: 1763
Reputation: 562
If you have a closer look at the target
directory, you'll see how views are compiled and the packages are made:
Ok(views.html.group.view())
You can also import like this:
@import views.html.group._
//...
Ok(view())
Upvotes: 3
Reputation: 11280
The way the template engine works is that a template defined as:
/views/application/index.scala.html
Will be turned into a class:
views.html.application.index
So basically views.html
is always kept as a prefix. Cf. the Play template documentation.
In your case that means it should be
Ok(views.html.customers.list(...))
Upvotes: 7