基本Scala Template.String正在显示

时间:2013-07-05 18:24:25

标签: playframework

我有一个遵循模式的基本模板: 标题,页眉,页脚。

这是我的基本模板(“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)(“主页 -   Nomad“){您的电子邮件是test@example.com} {Header} {页脚   }

1 个答案:

答案 0 :(得分:1)

也许解析器没有按照您期望的方式解释index.scala.html。尝试

@(email: String)

@main ("Home") {
    Your email is @email.
} {
    Header
} {
    Footer
}