常见的模式是创建包含样板的模板,并采用
HTML类型的参数.让我们说:
main.scala.html
@(content: HTML)
@header
// boilerplate
@content
// more boilerplate
@footer
实际上,您并不需要使用此方法分隔页眉和页脚.
您的UsersView.scala.html然后如下所示:
@main {
// all your users page html here.
}
您通过将其作为参数传递包装UsersView.
你可以在samples中看到这个例子
我通常的主模板有点涉及,看起来大致如下:
@(title: String)(headInsert: Html = Html.empty)(content: Html)(implicit user: Option[User] = None)
@title// bootstrap stuff here
@headInsert
@menu(user)
@content
这样,模板可以传入头部插入和标题,并使用户可用,当然还有内容.