-
Notifications
You must be signed in to change notification settings - Fork 236
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
Issues with yield
#433
Comments
http://trailblazer.to/gems/cells/api.html#yield The |
Actually, it's not the I can't remember exactly but there was some problem...?!?!?! |
I have the same problem, works fine if you pass the block from a normal rails view, but not from another cell. Some workaround for this? |
It looks like the Running into a similar issue also trying to make it work for something like panels. With the above code, if I call the block that is passed to (Otherwise cells has been a really great experience and it brings a lot of fresh air into every-day development, thank you!) Update: A workaround, if you are using Rails, could be to wrap the block in a capture call: = cell(SharedComponents::PanelCell, nil, title: model.title) do
- capture do
%p Hello |
I have a similar problem but where the block somehow gets yielded both where yield is called and above the cell itself. Using EDIT: Nevermind, that's a separate issue. |
The problem is the way ERB is implemented for Rails views: it writes to a stupid instance variable and then Rails changes this variable (aka output buffer) globally when capturing - it's a horrible hack that "makes it work". The solution is to use our ERBse gem and Cells, only, because there is no global |
@adambedford it should work with: = cell(SharedComponents::PanelCell, nil, title: model.title).() do
%p hello world |
@ushis Can you share a bit of code on how this works? I am not able to get it to work properly. |
FWIW, making a helper to clean up the markup in your templates works: def component(cell_class, opts, &body)
cell(CardBoxCell, nil, opts).() do
capture(&body)
end
end Cell view: class CardBoxCell < ApplicationCell
def title
options[:title]
end
end Cell template: .card-title-bar
.title= title
.card-container
= yield Then in your plain Rails views: = component(CardBoxCell, title: "Hi") do
.content-piece
p Inside part 2 |
I have a cell,
PanelCell
, which renders a bootstrap panel andyield
s where the panel body belongs. I'm getting ano block given (yield)
error when trying to render the page.Code is as follows:
This is being invoked here (from another cell
show.haml
):I would expect
<p>Hello</p>
to be rendered in place of theyield
, but it is blowing up.Am I running up against a technical limitation of Cells or just misunderstanding the implementation?
The text was updated successfully, but these errors were encountered: