Play Framework custom views directory

463 Views Asked by At

I found an answer to my question, however implementing it still causes errors. The only difference being the version of the Play framework

So, I've created a custom directory within app as follows:

app
  └ custom
         └ controllers
         └ models
         └ views

When trying to access views from within a controller with this code:

Ok(custom.views.html.index())

I get a compile error as follows:

object custom is not a member of package views

The answers also suggests to interrogate the corresponding target/... directory which, upon inspection, does has the class in the correct structure: custom.views.html.list

Any suggestions?

If I've omitted any necessary information, please let me know and I'll update my question as soon as I can

Thank you in advance

1

There are 1 best solutions below

0
On

If you check the Twirl project (Play's templating engine) on Github, you'll find the answer:

To configure the source directories where template files will be found, use the sourceDirectories in compileTemplates key. For example, to have template sources alongside Scala or Java source files:

sourceDirectories in (Compile, TwirlKeys.compileTemplates) := (unmanagedSourceDirectories in Compile).value