Which custom global helpers you use?

Hello,

I am interested to know what kind of global custom helpers people use.
Maybe it can inspire some1 or we can discuss good patterns for them.
As I am not sure if my helpers are best way how to accomplish what I need.

So these are my:
firstThree - simple first 3 items from array
firstFour - simple first 4 items from array
sortByNum - math based sort above array of objects based on parameters itemProperty and ascending/descending
sortByStr - same as above for strings

Most of these I use with combination of some expand button to show all results if needed.
But as querying subdocument arrays (or keeping them ordered in DB and than using slice) is such pain, I decided to most of the time send whole array and do these operations on client.
These are usually denormalized data attached to current user viewed document consisting of minimal amount of info to show them.

I just have one called debug that is pretty straightforward

Template.registerHelper('debug', function () {
  console.log(this);
});
4 Likes
Handlebars.registerHelper("formatDate", function (date, format) {
  return moment(date).format(format);
});

Handlebars.registerHelper("or", function (left, right) {
  return left || right;
});

I have literally that same format date helper

Thx for input guys. And that is why I started this topic.
Cause we have a lot of docs how various calls works, but no best practices regarding some topics :smiley:
Still using old Handlebars.registerHelper ? I also seen a lot of people still using rendered etc… strange :smiley: