【发布时间】:2014-10-10 16:03:59
【问题描述】:
我有一个名为 mainBody 的模板,格式如下:
@(title: String)(html: Html, moreScripts: Html = Html(""))
我可以这样称呼它
views.html.mainBody("All properties")(views.html.showProperties(list))
views.html.showProperties() 是另一个模板。我的印象是模板只是返回Html 的函数。但是,如果我将其扩展到:
views.html.mainBody("All properties")(views.html.showProperties(list), views.html.showPropertiesScripts)
views.html.showPropertiesScripts 只是一个带有一些 HTML 代码的模板,我得到了错误:
play.PlayExceptions$CompilationException: Compilation error[type mismatch;
found : views.html.showPropertiesScripts.type
required: play.twirl.api.Html]
at play.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27) ~[na:na]
at play.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27) ~[na:na]
at scala.Option.map(Option.scala:145) ~[scala-library-2.11.2.jar:na]
at play.PlayReloader$$anon$1$$anonfun$play$PlayReloader$$anon$$taskFailureHandler$1.apply(PlayReloader.scala:234) ~[na:na]
at play.PlayReloader$$anon$1$$anonfun$play$PlayReloader$$anon$$taskFailureHandler$1.apply(PlayReloader.scala:229) ~[na:na]
我不明白这一点。而不是预期的类型Html,views.html.showPropertiesScripts 是views.html.showPropertiesScripts.type?这是什么?为什么views.html.showPropertiesScripts 不是Html 类型(就像我的其他模板一样)?
【问题讨论】: