Skip to content

Instantly share code, notes, and snippets.

@dburles
Created August 22, 2014 13:21
Show Gist options
  • Save dburles/d2ea61aa6ccb3295bea6 to your computer and use it in GitHub Desktop.
Save dburles/d2ea61aa6ccb3295bea6 to your computer and use it in GitHub Desktop.
Router.static = function(options) {
options = options || {};
if (! options.path)
throw new Meteor.Error("Router.static: options.path is required");
return {
where: 'server',
path: options.path,
action: function() {
var render = _.isFunction(options.render) ?
options.render() : options.render;
this.response.writeHead(200, { 'Content-Type': 'text/html' });
this.response.end(render);
}
};
};
Router.handlebars = function(options) {
options = options || {};
options.data = options.data || {};
if (! options.template)
throw new Meteor.Error("Router.handlebars: options.template is required");
if (! options.path)
throw new Meteor.Error("Router.handlebars: options.path is required");
return {
where: 'server',
path: options.path,
action: function() {
var data = _.isFunction(options.data) ?
options.data() : options.data;
this.response.writeHead(200, { 'Content-Type': 'text/html' });
this.response.end(options.template(data));
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment