I'm just learning Meteor and I've defined a few helpers that I use in my templates.
I've noticed that I can do this in two different ways, but which solution is considered best practice? And why?
Solution 1
UI.registerHelper('firstChar', function (name) {
return name.charAt(0);
});
Solution 2
Template.registerHelper('firstChar', function (name) {
return name.charAt(0);
});
You should stick to solution 2, because this is what is currently documented : https://docs.meteor.com/#/full/template_registerhelper
The first solution use the previous namespace to define Spacebars helpers (UI
), and has been deprecated for months.