-
Notifications
You must be signed in to change notification settings - Fork 26
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
Q: Is Iron Router able to render components via yield? #44
Comments
Hm, no. :-( This would just render the logic-less template content. Not a component. You could probably do |
It seems it should work easily. You just have to use a controller with a different var originalLookupTemplate = RouteController.prototype.lookupTemplate;
RouteController.prototype.lookupTemplate = function () {
if (var component = BlazeComponent.getComponent(this.lookupOption('template'))) {
return component.renderComponent();
}
return originalLookupTemplate.apply(this);
}; |
Now that I am thinking, probably it could be possible to create a JavaScript class which is both an |
Oh wow, thanks for looking that up so fast. I think I will just use that prototype patch for now but were you thinking of doing something in particular with Iron Router or can I just close this? |
We could probably made that into a package. Or push them upstream with a weak dependency in iron-router. |
Does it work or does it not work? |
It does, sorry I messed up. |
So what did you want to do about this? Did you want to create a package for making BC compatible with IR? |
Patch into Meteor changing all necessary bits to have officially all extension points needed by Blaze Components was just merged into its Based on that I made this pull request to Iron Router: iron-meteor/iron-dynamic-template#11 If it is merged in Blaze Components should work out of the box with iron router. |
@rclai: Could you test if using that branch of Iron Router works for you? (You do not have to upgrade to latest Meteor, because at the moment Blaze Components monkey-patch it with what was currently merged in.) |
Try with 0.9.1 version. |
Are you talking about this branch? |
Yes. |
For some reason I got this error:
|
Why you have a top level constraint on |
Oh whoops I forgot to |
Okay, my routes error out with this now:
|
You will have to give more information. :-) Like, what exactly does not work. |
BTW, you do not need the patch above anymore. |
Huh? So am I supposed to just upgrade to 0.9.2 and that's it? |
Yes. Just upgrade to 0.9.2 and use the |
Oh, well it's not working, for some reason it (iron layout branch) breaks iron:controller and I can't visit any route. It shows the error in the client-side. |
Hm. Can you make a small example where it breaks? |
I'll try that later, but the error happens here. |
This is really strange. I think there is maybe some mismatch of versions you have? Do you have everything on your latest version? What does |
|
I found a way to render a Blaze Component without having to use the Router.route('/my-route', {
'name': 'routeName',
action: function () {
// My solution to make sure the component doesn't get re-rendered in case I had
// multiple routes using the same template. In most cases you won't need this check.
if (!BlazeComponent.getComponentForElement($('#MyComponentId').get(0))) {
this.render(BlazeComponent.getComponent('MyComponentRegisteredName').renderComponent());
}
}
}); |
The easiest solution I found is to simply wrap the component into a normal template.
You would then point the router to render |
I suggest you use Flow Router. That one is the one I am using in my projects. See example app here. I have some code made which would make Iron Router easier to use (route would be the same as component), but I have not yet fixed all the quirks. |
See #79. |
Will check it out, was not aware of it yet. (What is Meteor's recommendation for routing these days anyway?) |
Iron Router or Flow Router, but guide now mentions only Flow Router. |
I did use the template proxy method at some point. But I'm more inclined to using blaze layout to render these components now. |
The text was updated successfully, but these errors were encountered: