Hi,
I’m building a CMS which uses Iron Router . It’s at a very early stage but I want to be able to dynamically create a template based on a page source. If the page is changed I need the template to be destroyed, recreated with the new page source and then rendered.
Basically I think that I need an autorun inside an action as the psuedo code below outlines. It doesn’t of course work. Does anyone one know if this is even possible? I have everything else working but I just cant figure out how to make it reactive on the page source
Thanks
Rob
Router.route('/:name', {
waitOn: function() {
return Meteor.subscribe('things');
},
action: function() {
var router = this;
Tracker.autorun = function() {
var thing = Things.find();
if(thing) {
Template['thing'] = buildANewTemplateUsing(thing);
router.render(Template['thing']);
}
}
return whatShouldBeReturnedHere;
}