[英]Play2 Framework Template parameters
I'm trying to develop a template which has the content in the middle (link the main.scala.html) of the page. 我正在尝试开发一个模板,该模板的内容位于页面的中间(链接main.scala.html)。
Here is my Codes 这是我的密码
The Template of the mainPage (name: test.scala.html) mainPage的模板(名称:test.scala.html)
@(title: String)(content: Html)
<p> Some HTML Stuff </p>
@content
The secon Page (name: test2.scala.html) secon页面(名称:test2.scala.html)
@(test:String)
@test("test2"){
<p> Hello World </p>
}
The controller 控制器
public class Admin extends Controller {
public static Result test(){
return ok(test.render("test"));
}
public static Result test2(){
return ok(test2.render("test2"));
}
}
On this way it don't work. 这样就行不通了。 May be there is somebody who can help me 可能有人可以帮助我
this must be a compile error, because your template requires two arguments. 这必须是编译错误,因为您的模板需要两个参数。
//scala template
@(title: String)(content: Html)
<p> Some HTML Stuff </p>
@content
// java call
public static Result test(){
return ok(test.render("test"));
}
you have to pass some Html to the test template 您必须将一些HTML传递给测试模板
your java call could be like 你的java调用可能像
return ok(test.render("test",test2.render("test2")));
but in your case you should just call the test2 template, because your test-template is more like a wrapper. 但是在您的情况下,您应该只调用test2模板,因为您的测试模板更像是包装器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.