Chris Brakebill
Web and mobile developer

Replies Photos GitHub Now RSS

UI.registerHelper

Sometimes in Meteor you need to use the same helper across templates. For example, if you have several views with admin controls, you might want a helper to help you control who sees those. It would be a pain to add that function to each template. Luckily, Meteor provides the ability to create a new global helper via UI.registerHelper.

UI.registerHelper takes two parameters: the name of the helper as a string, and the function to be called. So to add my admin helper I might do something like this.

	UI.registerHelper('admin', function() {
		return userIsAdmin();
	});

UI.registerHelper is an excellent tool to prevent repeating code and to centralize global template functionality.

TweetTwitter