I am using Handlebars to render data in a table.
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:
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.
But is that the only best way?
Nope. As per their document you can do this in many ways. I would do this way.
{{getOutputByParameters param1 param2}}
Handlebars.registerHelper('getOutputByParameters', function(param1, param2){
//do your stuff here.
})