【发布时间】:2011-10-22 13:32:34
【问题描述】:
我想将字段名称作为参数传递给custom Play! framework tag:
#{ifError ${_field}}
<ul class="err">
#{errors ${_field}}
<li>${error}</li>
#{/errors}
</ul>
#{/ifError}
但我得到的只是例外:
Template execution error (In /app/views/tags/errorList.html around line 1)
Execution error occured in template /app/views/tags/errorList.html. Exception raised was MissingMethodException : No signature of method: Template_1008.$() is applicable for argument types: (Template_1008$_run_closure1_closure2) values: [Template_1008$_run_closure1_closure2@2da75e1b] Possible solutions: _(java.lang.String), is(java.lang.Object), run(), run(), any(), get(java.lang.String).
play.exceptions.TemplateExecutionException: No signature of method: Template_1008.$() is applicable for argument types: (Template_1008$_run_closure1_closure2) values: [Template_1008$_run_closure1_closure2@2da75e1b]
如何将参数传递给我的代码?
解决方案
我稍微修改了“Codemwnci”的解决方案,最终得到以下模板代码:
#{ifError _arg}
<ul class="err">
#{errors _arg}
<li>${error}</li>
#{/errors}
</ul>
#{/ifError}
这个模板是这样调用的#{errorList 'document.title' /}
【问题讨论】:
标签: java tags playframework