Reputation: 9549
I write an simple index.scala.html in view package
@import controllers.Application.AuthenticatedRequest
@(posts: Iterator[Post], message: String = "" )(implicit request: AuthenticatedRequest)
.....
the error is:
[error] F:\Kepler\blog\app\views\posts\index.scala.html:2: ')' expected but '='
found.
[error] @(posts: Iterator[Post], message:String = "")(implicit request: Authenti
catedRequest)
[error] ^
I think it is correct way to set the message default value as "". anyonw know why here is expected ')' instead of '='
Upvotes: 0
Views: 122
Reputation: 6805
As @Max mentioned the first line should contain parameters, and if any parameter type isn't recognized without importing it you should either fully qualify the type name, which in your case should look like:
@(posts: Iterator[Post], message: String = "" )(implicit request: controller.Application.AuthenticatedRequest)
Or if you plan to use the type often in the templates parameters list, then you can specify additional imports in the F:\Kepler\blog\project\Build.scala
file, like
val main = play.Project(appName, appVersion, appDependencies).settings(
..., // your settings here like resolvers, etc.
templatesImport += "controllers.Application._",
templatesImport += "models._", //etc.
... // further settings or the end of the list - remember: last item without coma
)
Then the templates are generated with the imports visible to the parameters list.
Upvotes: 1
Reputation: 2095
Play will expect you declare all template parameters at first line. Try this
Try to swap with import line
@(posts: Iterator[Post], message: String = "" )(implicit request: AuthenticatedRequest)
@import controllers.Application.AuthenticatedRequest
The error message is misleading though
Upvotes: 1