From 3a824c2026941a5fafc59eadfe1b718fbea179b9 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:53:24 +0100 Subject: [PATCH] Fix up some hacks that generate errors when used with Mab --- stoptime.rb | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index a67f41e..709f870 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -78,20 +78,28 @@ module StopTime end # = The Stop… Camping Time! Markaby extensions -module StopTime::Helpers +module StopTime::Mab SUPPORTED = [:get, :post] - # Adds a method override field in form tags for (usually) unsupported - # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. - def tag!(tag, *attrs) - return super unless tag == :form && block_given? - attrs = attrs.last.is_a?(Hash) ? attrs.last : {} - meth = attrs[:method] - attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) - super(tag, attrs) do - input :type => 'hidden', :name => '_method', :value => meth if override - yield - end + # # Adds a method override field in form tags for (usually) unsupported + # # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. + # def tag!(tag, *attrs) + # return super unless tag == :form && block_given? + # attrs = attrs.last.is_a?(Hash) ? attrs.last : {} + # meth = attrs[:method] + # attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) + # super(tag, attrs) do + # input :type => 'hidden', :name => '_method', :value => meth if override + # yield + # end + # end + + def tag!(name, *args) + Kernel.p [name, args] + content = args.shift unless args.first.is_a?(Hash) + attrs = args.inject { |a,b| a.merge(b) } + Kernel.p [name, content, args] + super(name, content, attrs) end end