I just needed to learn this for the Play 2.6.x platform. You can add an object to the template in accordance with the documentation: https://www.playframework.com/documentation/2.6.x/ScalaTemplatesDependencyInjection .
I implemented a simple example (a bit far-fetched), and I used scala:
test.scala.html:
@this(configuration: play.api.Configuration)
@(key: String)
config = @configuration.get[Seq[String]](key).mkString(", ")
HomeController.scala
package controllers
import javax.inject._
import play.api._
import play.api.i18n._
import play.api.mvc._
@Singleton
class HomeController @Inject()(cc: ControllerComponents, testView: views.html.test) (implicit configuration: Configuration) extends AbstractController(cc) with I18nSupport{
def test() = Action { implicit request =>
Ok(testView("play.i18n.langs"))
}
}
routes:
GET /test controllers.HomeController.test()
views.html.test, . @this(configuration: play.api.Configuration) . Play , Configuration.
, . , ... , , , , , implicit configuration: play.api.Configuration , : @(message: String)(implicit messagesProvider: MessagesProvider, configuration: play.api.Configuration)
. , , , .