It seems like in Play framework templates,
there is an implicit "@import models._" and "@import play.api.data.Form" because my code:
@(title: String)(myForm: Form[User])
<!DOCTYPE html>
<html>
....
</html>
works without having to put explicit import statements after the first line. This issue has been raised in the past: https://groups.google.com/d/msg/play-framework/7FT68jd5asU/xYF0VNySJYcJ
What other classes/objects are implicitly imported?
As of Play 2.3 I use this line in
build.sbt
You're right, Play Framework automatically add some
import
statements to all templates.You can find these "default imports" in the
PlaySettings
trait from Play source code : https://github.com/playframework/Play20/blob/2.1.x/framework/src/sbt-plugin/src/main/scala/PlaySettings.scalaIf you need to, you can add some additional imports in the project settings defined in your Build.scala :
You can look up the file : https://github.com/playframework/playframework/blob/master/framework/src/sbt-plugin/src/main/scala/PlayImport.scala#L40
All those mentioned there are imported.
Additionally,
templatesImport += "com.acme._"
is enough in 2.2.X to import all the files from a package i.e. in the filebuild.sbt
.