Template Helper as Object instead of Function?


#1

I see in the examples, and have created a template helper as a function that processes some type of job.
My question is , is it possible to create a template helper as an object such that you can call different functions from within the object.

Something like this.


Template.registerHelper("someObject", {
	getPeople: function () {
		return something;
	},
	getFriends: function () {
		return somethingElse;
	}
});

<template name="foo">
	<h1>{{someObject.getPeople 'hello'}}</h1>
</template>


#2

That is quite easier:

someObject = {
  getPeople: function() {
    return something;
  },
  getFriends: function() {
    return something;
  }
}


Template.registerHelper('someObject', function() {
  return someObject;
});

See as an example: https://atmospherejs.com/4commerce/meteor-namespace-template-helper

Github source: https://github.com/4commerce-technologies-AG/meteor-package-meteor-namespace-template-helper/blob/master/meteor-namespace-template-helper.js