Skip to content

Instantly share code, notes, and snippets.

@doowb
Created March 19, 2014 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doowb/9650061 to your computer and use it in GitHub Desktop.
Save doowb/9650061 to your computer and use it in GitHub Desktop.
Example of setting up expected api from environments using helpers.
var expects = function(config, spec) {
for(var k in spec) {
if (config[k] === 'undefined') {
config[k] = spec[k];
}
}
};
var spec = {
context: function() { return {}; },
registerHelpers: function() { }
};
module.exports = function (config) {
expects(config, spec);
Library.addHelper('foo', function (bar) {
var context = config.context();
var baz = context[bar] || 'default';
return 'Hello ' + baz;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment