我在AWS中使用Play 2.6作为我的Web应用程序。到目前为止,我一直在为应用程序使用一个HTML5 + CSS主题。但是,作为根据用户需求使主题可更改的一部分,我需要选择并加载用户选择的主题。如何在Play-Java Controllers中使用动态模板?
public Result index() {
String theme = "skeleton"; // Will be a user selection finally.
String workflow = "mainpage"; // this will be different for each page
return ok(index.render(theme, workflow));
}
对于workflow = mainpage,我目前在mainpage.scala.html
中使用默认主题<body>
@* And here's we render the `Html` object containing
* for the the main page content. *@
@mainpage()
</body>
选择基于主题和工作流程的scala html模板是否可行 - 类似于......
@theme.@workflow.scala.html
index.scala.html中的?
或者Play Framework中是否有动态主题选择的最佳实践? 当我尝试上述内容时,我会进入html
@ theme。@ workflow.scala.html作为输出。基本上没有提取内容。
答案 0 :(得分:0)
您可以阅读此answer
您可以在控制器或视图中切换模板值,但对我来说,我认为最好在控制器上切换它,并指出视图的哪个文件夹。您可以将选定的主题保存在文件或数据库中,并记住设置默认主题。