lib/haml/helpers/action_view_mods.rb in haml-2.2.24 vs lib/haml/helpers/action_view_mods.rb in haml-3.0.0.beta.1

- old
+ new

@@ -123,16 +123,13 @@ def is_haml? @template_object.send :is_haml? end - def content_tag(*args) - html_tag = content_tag_with_haml(*args) - return html_tag unless respond_to?(:error_wrapping) - return error_wrapping(html_tag) if method(:error_wrapping).arity == 1 - return html_tag unless object.respond_to?(:errors) && object.errors.respond_to?(:on) - return error_wrapping(html_tag, object.errors.on(@method_name)) + unless defined?(ActionView::Helpers) && defined?(ActionView::Helpers::ActiveRecordInstanceTag) + alias_method :content_tag_without_haml, :content_tag + alias_method :content_tag, :content_tag_with_haml end end if Haml::Util.ap_geq_3? module FormTagHelper @@ -158,11 +155,13 @@ module FormHelper def form_for_with_haml(object_name, *args, &proc) if block_given? && is_haml? oldproc = proc - proc = proc {|*args| with_tabs(1) {oldproc.call(*args)}} + proc = haml_bind_proc do |*args| + with_tabs(1) {oldproc.call(*args)} + end end res = form_for_without_haml(object_name, *args, &proc) res << "\n" if block_given? && is_haml? res end @@ -183,11 +182,14 @@ concat haml_indent end concat haml_indent end res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n" - concat "\n" if block_given? + if block_given? + concat "\n" + return Haml::Helpers::ErrorReturn.new("form_tag") + end res else form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) end end @@ -207,9 +209,10 @@ end concat haml_indent end form_for_without_haml(object_name, *args, &proc) concat "\n" if block_given? && is_haml? + Haml::Helpers::ErrorReturn.new("form_for") if is_haml? end alias_method :form_for_without_haml, :form_for alias_method :form_for, :form_for_with_haml end end