[英]Handlebars : What is the best way to pass multiple parameters to a registerHelper function?
I am using Handlebars to render data in a table. 我正在使用Handlebars在表格中呈现数据。
One of the data items needs processing, which takes a few parameters into account in order to provide outcome. 其中一个数据项需要处理,其中考虑了一些参数以便提供结果。
The templated text example : 模板文本示例:
{{getOutputByParameters param1=DataFieldName1 param2=DataFieldName2}}
And corresponding registerHelper would be written as: 相应的registerHelper将被写为:
var __this = this;
Handlebars.registerHelper('getOutputByParameters', function(params){ __this.getOutputByParameters(params.hash.param1, params.hash.param2)})
I figured that handlebars would pass an array of these parameters, which I can access using hash property. 我认为把手会传递这些参数的数组,我可以使用hash属性访问它们。
But is that the only best way? 但这是唯一最好的方式吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.