I was wondering if it is possible to override/add to the template paths for Playframework? For instance, the default templates are looked under views folder and are compiled automatically. These templates are further reachable directly using a URL without any additional config.
---app
|-controllers
|-models
|-templates //How do I compile templates under this folder?
|-views
What I would like to know is if it is possible to add a custom path in addition to the views
folder that is also compiled with the build process. Alternatively, is it possible to block certain templates to be not reachable by direct URL ?
Thanks in advance!
Under the
app
directory, Play should automatically compile anything that looks like a Twirl template - that is, has a registered extension such as*.scala.html
- regardless of what directory it's in. Theviews
directory is just a convention, and compiling templates under anapp/templates
directory should already happen.If you open an SBT prompt you can verify this by running the command:
Which should give you something like:
For adding a templates directory outside the
app
folder, you should be able to add something like the following in yourbuild.sbt
(for example, the directoryextra_templates
):