Usage
Just keep using your deprecated block helpers, they can be converted once the transition to rails 3 is complete.
<% form_for xxx do |f| %> still works <% end %>
Code
# make <% helper do %> work
block_concat = [
[ActionView::Helpers::FormHelper, :fields_for],
[ActionView::Helpers::FormBuilder, :fields_for],
[ActionView::Helpers::FormHelper, :form_for],
[ActionView::Helpers::FormTagHelper, :form_tag],
[ActionView::Helpers::TagHelper, :content_tag],
[ActionView::Helpers::UrlHelper, :link_to],
[ActionView::Helpers::JavaScriptHelper, :javascript_tag],
[ActionView::Helpers::CacheHelper, :cache],
]
ERB_EXTENSION = '.erb'.freeze
block_concat.each do |klass, method|
klass.class_eval do
without = "#{method}_without_concat".to_sym
alias_method without, method
define_method(method) do |*args, &block|
result = send(without, *args, &block)
if block && block.source_location.first.include?(ERB_EXTENSION) # called from a erb template ?
(@template || self).concat(result) # deprecated erb concat helper
""
else
result
end
end
end
end