Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grouping Play 2.0 views into packages/folders

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.

like image 394
Kris Avatar asked Aug 07 '13 11:08

Kris


1 Answers

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(...))
like image 198
gourlaysama Avatar answered Oct 17 '22 17:10

gourlaysama