Skip to content

Instantly share code, notes, and snippets.

@kodie
Created February 8, 2017 17:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kodie/126ca19c8a5a918ccddab1c4348aae8b to your computer and use it in GitHub Desktop.
Save kodie/126ca19c8a5a918ccddab1c4348aae8b to your computer and use it in GitHub Desktop.
Meteor template helper to access public settings
Template.registerHelper('meteorSettings', function(settings) {
var setting = Meteor.settings.public;
if (settings) {
var eachSetting = settings.split('.');
for (i = 0; i < eachSetting.length; i++) {
setting = setting[eachSetting[i]];
}
}
return setting;
});
<template name="home">
<!--
Basically the same as doing this: (except you can't do this)
{{#if Meteor.settings.public.instagram.access_token}}
-->
{{#if (meteorSettings 'instagram.access_token')}}
<div class="instagram"></div>
{{/if}}
<!--
You can also set Meteor.settings.public to a variable to access multiple settings
-->
{{#let settings=meteorSettings}}
{{settings.instagram.access_token}}
{{/let}}
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment