<%= content_tag :div, class: "strong" do %>
Hello world!
<% end %>
# File actionview/lib/action_view/helpers/tag_helper.rb, line 103
def content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
if block_given?
options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
content_tag_string(name, capture(&block), options, escape)
else
content_tag_string(name, content_or_options_with_block, options, escape)
end
end
# File actionview/lib/action_view/helpers/capture_helper.rb, line 36
def capture(*args)
value = nil
buffer = with_output_buffer { value = yield(*args) }
if string = buffer.presence || value and string.is_a?(String)
ERB::Util.html_escape string
end
end
obj.your_method { |item| ... }
def your_method(..., ..., &block)
block.call(:somth)
end