In my Play HTML template inside my custom
module, I have the following line of code:
<script type="text/javascript" src="@controllers.core.routes.WebJarAssets.at(WebJarAssets.locate("jquery.min.js"))"></script>
This references a WebJarAssets
class in the core
module that looks like this:
package controllers.core
import javax.inject._
import play.api.http.HttpErrorHandler
import play.api.{Environment, Configuration}
class WebJarAssets @Inject()(errorHandler: HttpErrorHandler, configuration: Configuration, environment: Environment) extends controllers.WebJarAssets(errorHandler, configuration, environment)
Please note that I have also included the following line in build.sbt
in the custom
module:
"org.webjars" %% "webjars-play" % "2.5.0",
When starting the application, I receive the following error:
[error] /Users/john/DemoProject/modules/custom/app/views/custom/templates/main.scala.html:36: not found: value WebJarAssets
[error] <script type="text/javascript" src="@controllers.core.routes.WebJarAssets.at(WebJarAssets.locate("jquery.min.js"))"></script>
[error] ^
Judging from the implementation of WebJarAssets in earlier releases, there was no need to implement and inject an own controller for this (for example, see this tutorial).
What am I doing wrong? Do I even need a WebJarAssets
class for this (as I need web jar assets in many modules, I added this for now in the core
module). Furthermore, why do I need to manually inject it in the template and why is it not automatically resolved?
In case you wonder what manually inject means for me:
@(title: String, webJarAssets: WebJarAssets)(content: Html)(implicit messages:Messages)
<script type="text/javascript" src="@controllers.core.routes.WebJarAssets.at(webJarAssets.locate("jquery.min.js"))"></script>