Skip to content

Instantly share code, notes, and snippets.

@mhinton
Last active August 29, 2015 14:01
Show Gist options
  • Save mhinton/1365c9c7d2355e83ed85 to your computer and use it in GitHub Desktop.
Save mhinton/1365c9c7d2355e83ed85 to your computer and use it in GitHub Desktop.
Meteor: Trying to dynamically render a template
Template.gem_view.context = function() {
return {
contentTemplate: "gems"
};
};
Template.page.render_content = function() {
var context = this;
var html = Template.no_template_found;
if (context && context.contentTemplate) {
if (typeof Template[context.contentTemplate] !== "undefined") {
html = Template[context.contentTemplate];
}
}
return html;
}
/* here is the template for the code above */
<template name="page">
{{{render_content context}}}
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment