-
-
Save mattsoutherden/1664389 to your computer and use it in GitHub Desktop.
In a mounted engine with | |
isolate_namespace Foo | |
A Foo::BarController#index action looks for it's template in app/views/foo/bar/index.html.erb | |
However if I'm in that index template and do | |
render :partial => 'bar/baz' | |
Then the namespace is no longer applied. And it looks for the template in app/views/bar/_baz.html.erb |
Thanks, Piotr. I see what you mean regarding other partials.
Some random thoughts:
For the general use case:
If you're isolating your engine, then why would you want to be rendering global partials from within the plugin?
For our use case:
We want to create an engine which is effectively our whole app as a white-label solution. We will then include this gem in a parent app and, where required, we can take advantage of load paths to override templates from the engine. Given both engine and parent are the affectively the same app, I don't think the disconnect that namespacing provides is required. The parent app will also have the assets to customise the look and feel of each site.
To avoid having to reference the engine itself for each url helper
engine_name.foo_path()
can you see a problem with including all the engine helpers in the parent app?
include Website::Engine.routes.url_helpers
I think this maybe matches our circumstance better.
Regarding the general use case: there could be situation when you want to just require the main app to provide some kind of partials. Not sure if this is something that we should care about as those partials can also be namespaced. I guess that if we agree that this has no sense, 4.0 is a good time to change behavior.
Regarding including routes. It should work, but I can't guarantee that it will in every use case and you must ensure that engine's helpers are included before application helpers. Otherwise engine ones will have priority and you will override root_url and possibly other urls.
Also, if you want such thing, maybe you don't really want isolated engine?
I think that we have never explicitly discussed such cases, but it seems right. In other case you would not have ability to render partial without a namespace (well, there could be some special syntax to do that, but there is no such thing right now). Do you think that it should behave differently?