I have this in my Rules file:
compile '/gallery/' do
filter :haml
layout :'gallery'
end
...
compile '/' do
filter :haml
layout :'default'
end
...
route '/gallery/' do
nil
end
...
route '*' do
item.identifier.chop + '.' +item[:extension]
end
, so now my content/index.html goes through haml filter and compiles as output/index.html all well and good. My content/gallery.html holds this code which also goes through haml:
#gallery-container
%ul.items-small
%li.item
- @item.children.each do |img|
%a{:href => "#{img.path}"}
%ul.items-big
%li.item-big
- @item.children.each do |img|
%a{:href => "#"}
%figure
%img{:src => "#{img.path(:rep => :thumbnail)}"}
%figcaption.img-caption Caption
,it gathers some images in content/gallery/
folder and when I set routing to output/gallery/index.html
(to see the preview output spit out) I do get what I want, so all well and good still.
But now I would like to use that generated code as partial in my content/index.html
, however
when I try to include it like =render 'gallery'
I do not get my expected code. In turn I get error message LocalJumpError: no block given (yield)
.
What should be in my layouts/gallery.html
file?, if I put there <%= yield %>
I get the above error, If i remove =render 'gallery'
there is no error,
But if I put some text in layouts/gallery.html
and have again that =render 'gallery'
in my index.html I get literally that text in layouts/gallery.html
, so it gets included and without error. So should I <%= yield %> that gallery code I am expecting into layouts/gallery.html
and then call =render 'gallery' from index.html?? But that does not work. Also that layouts/default.html
already has its own yield which is working, and then I try to use that =render in item which would be compiled through that yield. Am i doing it wrong way? I am lost!
All of my layouts file are :erb
filtered.
So my question would be how to include this partial. Thanks!
After digging through the code I found another solution to this.
The render method is part of
Helpers::Rendering
, if you look at the source code you see that it callsfilter_for_layout
from the rules (github).You therefore just need to add the following to your
Rules
file:That way as the gallery layout is rendered it will pass through the haml filter like the other layouts.