我有一个遵循模式的基本模板:标题、页眉、页脚。
这是我的基本模板(“main.scala.html”)。所有参数都是可选的,除了content: Html
.
@(title:String = "Untitled")(content: Html)(header: Html = null)(footer: Html = null)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@title</title>
</head>
@header
<body>
@content
</body>
(C) 2013
@footer
</html>
我将此基本模板与以下“index.scala.html”模板一起使用。
@(email: String)
@main ("Home")
{
Your email is @email.
}
{
Header
}
{
Footer
}
我在控制器中使用索引函数中的索引模板。
def index = Action {
request => {
logRequest(request)
request.session.get("auth").map(
email => {
Ok(views.html.index(email))
}
) getOrElse {
Redirect(routes.Application.login)
}
}
}
问题是,当我尝试访问索引时,我得到了这个:
BaseScalaTemplate(play.api.templates.HtmlFormat$@a335c3b) ("Home -- Nomad") { Your email is test@example.com } { Header } { Footer }