-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controllers not extending yieldTemplates #249
Comments
@FredericoC, I think issue #150 is about the same. You can check out my comment there. |
What's happening here is your Router level config is overriding the RouteController prototype property. It's a bit of a confusing paradigm and maybe we should change it. In general, options override prototype properties in iron-router. For example: Controller = function (options) {
// if we got a value for yieldTemplates from options just use that, otherwise use whatever is currently attached to 'this'
this.yieldTemplates = options.yieldTemplates || this.yieldTemplates;
};
Controller.prototype.yieldTemplates = {}; So when you globally configure properties on the Router, we pass those along as options to the RouteController. So it's not really inheriting, it's just being passed as an option which is completely overriding the prototype property. It's possible allowing this behavior was a mistake :-). If you're using RouteControllers I would not use global router config at all (except for autoRender and autoStart etc). Instead, create a super controller and just inherit from that. ApplicationController = RouteController.extend({
yieldTemplates: {}
});
ChildController = ApplicationController.extend({
// inherits yield templates
}); |
@cmather Is this still true with how the ApplicationController = RouteController.extend({
data: function(){
return {
user: Meteor.user()
}
}
});
ChildController = ApplicationController.extend({
data: function(){
return {
// I expected to inherit Meteor.User ?????
someData: {}
}
}
}); |
@cmather Still having this issue |
I have the following (Coffescript):
The "before" hooks extend perfectly, but the "yieldTemplates" property does not. If i use Coffescript native inheritance it will just throw and exception with "before" not defined (I can get the actual error if you want). If I define "projectHeaderNav: {to: 'header'}" in "Router.configure" it works fine.
Any ideas?
The text was updated successfully, but these errors were encountered: