Skip to content
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

Nested view; Trying to include top-level partials #11

Open
harlow opened this issue Aug 17, 2015 · 2 comments
Open

Nested view; Trying to include top-level partials #11

harlow opened this issue Aug 17, 2015 · 2 comments

Comments

@harlow
Copy link

harlow commented Aug 17, 2015

I'm running into an issue where I'm trying to include a partial from a nested view.

It works great from app/views/test.erb. However, the issue arises when I'm on the nested view app/views/dashboard/manage.erb.

app/views/dashboard/manage.erb
app/views/layouts/site.erb
app/views/layouts/dashboard.erb
app/views/shared/_analytics.erb
app/views/test.erb

It's trying to include the partial relative to that file:

screen shot 2015-08-17 at 4 50 10 pm

Let me know if there is already a way to include partials from nested views?

If not please let me know if it's something that I can contribute. I'm not sure the best way to go about so any suggestions would be appreciated. Maybe something like this:

1. Partial exists relative to current view?
2. Partial exists in base app view directory?
@yb66
Copy link
Owner

yb66 commented Aug 18, 2015

Hi @harlow ,

There's no intrinsic reason why this shouldn't work just because the partial is nested. Are you able to share the calling code used in app/views/dashboard/manage.erb, or just a very similar test case I can try?

iain

@harlow
Copy link
Author

harlow commented Aug 21, 2015

@yb66 yeah I'll throw together a gist this weekend w/ an example.

As far as I can tell the issue arises here: https://github.com/sinatra/sinatra/blob/18353f8e0fe8b1be10c1e56f3d7301deda841b4d/lib/sinatra/base.rb#L801

settings.views -> 'app/views/dashboard'

Which means that it will be looking for shared one directory up from app/views

@harlow harlow changed the title Nested view including base level partials Nested view. Trying to include top-level partials Aug 21, 2015
@harlow harlow changed the title Nested view. Trying to include top-level partials Nested view; Trying to include top-level partials Aug 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants