假设 View 文件夹中有两个 scala 模板
- file1.scala.html
- container.scala.html
现在我想将第一个模板从 Controller 传递到第二个模板(container.scala.html)。喜欢:
public class Application extends Controller {
static Result isItPossible()
{
Result theFile=ok(file1.render());
return ok(container.render(theFile));
}
}
这可能吗?如果是的话我该怎么做?
最佳答案
您可以将渲染的模板传递给容器
模板。 容器
需要有一些Html
参数:
容器.scala.html:
@(content: Html)
<p>Here's my content: @content </p>
从 Controller 内部:
public class Application extends Controller {
return ok(container.render(file1.render()));
}
关于java - 在 Play Framework 中的变量中获取 scala 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28400269/