helloworld example and it keeps failing with the following error on the first line of the template:`identifier' expected but `' found
This is the template it is failing on:
@(name: String, repeat: Int, color: Option[String])
@main("Here is the result:") {
<ul style="color: @color.getOrElse("inherited")">
@for(_ <- 1 to repeat) {
<li>Hello @name!</li>
}
</ul>
<p class="buttons">
<a href="@routes.Application.index">Back to the form</a>
</p>
}I am using Scala 2.1 and Play 2.1. Any ideas what this error means? This is taken from the hellowork example that comes with Play 2.1.
More details on my issue. I did not change anything in the sample code. Thanks for your help.
Main view below:
@(title: String)(content: Html)
<!DOCTYPE html>
<html>
<head>
<title>@title</title>
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
<script src="@routes.Assets.at("javascripts/jquery-1.6.4.min.js")" type="text/javascript"></script>
</head>
<body>
<header>
<a href="@routes.Application.index">@title</a>
</header>
<section>
@content
</section>
</body>
</html>Console Exception:
! @6dhjgk32b - Internal server error, for (GET) [/] ->
sbt.PlayExceptions$TemplateCompilationException: Compilation error[`identifier' expected but ` ' found]
at sbt.PlayCommands$$anonfun$43.apply(PlayCommands.scala:433) ~[na:na]
at sbt.PlayCommands$$anonfun$43.apply(PlayCommands.scala:409) ~[na:na]
at sbt.Scoped$$anonfun$hf5$1.apply(Structure.scala:581) ~[na:na]
at sbt.Scoped$$anonfun$hf5$1.apply(Structure.scala:581) ~[na:na]
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49) ~[scala-library.jar:na]
at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311) ~[na:na]
[warn] play - No application found at invoker initroutes
GET / controllers.Application.indexApplication.scala
/**
* Describes the hello form.
*/
val helloForm = Form(
tuple(
"name" -> nonEmptyText,
"repeat" -> number(min = 1, max = 100),
"color" -> optional(text)
)
)
// -- Actions
/**
* Home page
*/
def index = Action {
Ok(html.index(helloForm))
}When I take out all template code ( using @ ) and have a text only template ( something with<h1>Hello</h1> for example ), I see no issues. Once I add template code using @ event if it is an unused code block like the following I get that error. I am using eclipse + Scala and Play plugin on Windows 7.
@sidebar = {
<h1>Sidebar</h1>
}