-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Make possible rendering of a block with a layout and a collection. #13447
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,6 +412,15 @@ def test_render_layout_with_block_and_yield_with_params | |
@view.render(:layout => "layouts/yield_with_params") { |param| "#{param} Content from block!" } | ||
end | ||
|
||
def test_render_layout_with_collection_and_block_and_yield_with_params | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could make this a bit more readable without sacraficing line count: args = {layout: "layouts/yield_with_params", collection: %w[item1 item2], as: :item }
actual = @view.render(args) do |param, locals|
"#{param} Content from block! #{locals[:item]}:#{locals[:item_counter]}"
end
expected = %(Yield! Content from block! item1:0\nYield! Content from block! item2:1\n)
assert_equal expected, actual There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test started as a copy, they all look like this, I think it's readable enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was hard for me to read, even if the others are hard to read no reason we can't make this one better. At the end of the day it won't block the PR but are you happy with the Rails codebase being just good enough ? 😄 |
||
assert_equal %(Yield! Content from block! item1:0\nYield! Content from block! item2:1\n), | ||
@view.render(:layout => "layouts/yield_with_params", | ||
collection: %w[item1 item2], | ||
as: :item ) { |param, locals| | ||
"#{param} Content from block! #{locals[:item]}:#{locals[:item_counter]}" | ||
} | ||
end | ||
|
||
def test_render_layout_with_block_which_renders_another_partial_and_yields | ||
assert_equal %(partial html\nContent from block!\n), | ||
@view.render(:layout => "layouts/partial_and_yield") { "Content from block!" } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When calling
super
without arguments, ruby will automatically provide the arguments originally sent to the method.So, as the argument isn't modified here, explicitely specifying name doesn't seem useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super has a different signature
def _layout_for(name=nil)