Java 在Play框架中的变量中获取scala模板
假设视图文件夹中有两个scala模板Java 在Play框架中的变量中获取scala模板,java,scala,playframework,Java,Scala,Playframework,假设视图文件夹中有两个scala模板 file1.scala.html container.scala.html 现在我想将第一个模板从控制器传递到第二个模板(container.scala.html)。比如: public class Application extends Controller { static Result isItPossible() { Result theFile=ok(file1.render()); return o
public class Application extends Controller {
static Result isItPossible()
{
Result theFile=ok(file1.render());
return ok(container.render(theFile));
}
}
可能吗?如果是,我如何做?您可以将渲染的模板传递给
容器模板<代码>容器
需要一些Html
参数:
container.scala.html:
@(content: Html)
<p>Here's my content: @content </p>
值得一提的是,您不需要在控制器中组合包装容器,因为模板引擎能够使用布局()。在这种情况下,您可以这样使用它:
container.scala.html
@()(content: Html)
<p>Here's my content: @content </p>
@container() {
<b>this is content of <i>file1</i> template</b>
}
@container() {
<b>this is content of <i>file1</i> template</b>
}
public class Application extends Controller {
static Result itIsPossible() {
return ok(file1.render());
}
}