I want to use one helper function in another helper function. In the code below, I want to highlight the last name if it contains the word "Finch". For this, I have a helper class. If we use the hbs file, then the syntax will be {{highlight name}}. But how to use it, since I have to use it in another helper class.
Below is my code:
Handlebars.registerHelper('fullName', function(person) { return person.firstName + " " + person.lastName; }); Handlebars.registerHelper('highlight', function(person) { var item = (person.lastName).replace('Finch', '<span style="color: red">' + Finch + '</span>'); return new Handlebars.SafeString(item); });
Here is a working fiddle: http://jsfiddle.net/wC6JT/4/
Here is the fiddle where the helper helper is called: http://jsfiddle.net/wC6JT/3/ . This will not give any results, since we will get console errors for person.lastName that are not recognized in the auxiliary element "highlight".
I want to use the "highlight" helper in fullname helper for person.lastName. How can this be achieved.
Cindrella
source share