lib/haml/helpers/action_view_mods.rb in haml-1.0.5 vs lib/haml/helpers/action_view_mods.rb in haml-1.5.0

- old
+ new

@@ -10,17 +10,22 @@ if action_view_included class ActionView::Base alias_method :old_concat, :concat unless instance_methods.include? "old_concat" alias_method :old_form_tag, :form_tag unless instance_methods.include? "old_form_tag" + + alias_method :old_form_for, :form_for unless instance_methods.include? "old_form_for" end module Haml module Helpers - # This module overrides various helpers in ActionView to make them - # work more effectively with Haml. It's not available unless ActionView - # is installed. + # This module overrides various helpers in ActionView + # to make them work more effectively with Haml. + # It also defines several helper methods, + # available from a Haml template, + # which are only useful within the context of ActionView. + # It's not available unless ActionView is installed. # #-- # Methods in this module should be nodoc'd. #++ module ActionViewMods @@ -47,10 +52,29 @@ tab_up oldproc.call(*args) tab_down end end - old_form_tag(url_for_options, options, *parameters_for_url, &proc) + res = old_form_tag(url_for_options, options, *parameters_for_url, &proc) + "\n" + concat "\n" if block_given? && is_haml? + res + end + + def form_for(object_name, *args, &proc) # :nodoc: + if block_given? && is_haml? + oldproc = proc + proc = bind_proc do |*args| + tab_up + oldproc.call(*args) + tab_down + end + end + old_form_for(object_name, *args, &proc) + concat "\n" if block_given? && is_haml? + end + + def generate_content_class_names + controller.controller_name + " " + controller.action_name end end end end end