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

Problem sharing common layout folder between multiple gems #1742

Open
fgarcia opened this issue Aug 16, 2014 · 2 comments
Open

Problem sharing common layout folder between multiple gems #1742

fgarcia opened this issue Aug 16, 2014 · 2 comments
Milestone

Comments

@fgarcia
Copy link

fgarcia commented Aug 16, 2014

I have multiple gemified Padrino apps sharing a common layout. One of them has the main layout and the others point theirs to the central one.

I noticed that the layout setting will not take a full path, but I solved temporally this problem by calculating the relative path as I do in this example (lines 24-34 - highlight does not seem to be working today)

Since the path is relative from ./app/views/layouts it seems that Padrino requires the folder to exist, even if it is empty. Removing the empty layout causes the relative indirection to fail.

Ideally I would like being able to set a full path. Is there any technical reason preventing this?

Since git will ignore empty folders, other people sharing a central layout between gems will have to do some debugging because there is no warning/error explaining that the layout folder must exist even if empty.

@ujifgc
Copy link
Member

ujifgc commented Aug 17, 2014

Sinatra has the ability to render external layouts using :layout_options => { :views => '/absolute/path/to/views/folder/containing/layouts/folder/with/layouts' } options on a route definition, however this setting can not be set globally for an app.

The routine is here: https://github.com/sinatra/sinatra/blob/28af01e6af721c102b9d6d8abb39f4708a97d808/lib/sinatra/base.rb#L828-L832

To solve this problem just in Padrino we could remove super to this Sinatra render method and call #compile_template, template#render directly. This will spare us two super calls for every request.

Or if we want to be compatible we could bring this problem to @sinatra and @rkh.

@padrino/core-members ?

@ujifgc ujifgc modified the milestone: 1.0.0 Sep 5, 2014
@fgarcia
Copy link
Author

fgarcia commented Sep 7, 2014

Here goes an update for people having the same problem

I've just realized of this alternative hack:

render('/path/my/layout', :layout => nil) do
  render 'home/index',  :layout => nil
end

The downside is that I must be careful when adding my yield block to avoid the html tags being scaped.

I've just implemented this solution with a custom helper but I am not sure of any extra side effect. Although it is just a hack, at least this no longer requires the existence of an empty folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants