Fix up some hacks that generate errors when used with Mab
This commit is contained in:
parent
3f594d49d0
commit
0e2c9ee02e
1 changed files with 20 additions and 12 deletions
32
stoptime.rb
32
stoptime.rb
|
@ -78,20 +78,28 @@ module StopTime
|
||||||
end
|
end
|
||||||
|
|
||||||
# = The Stop… Camping Time! Markaby extensions
|
# = The Stop… Camping Time! Markaby extensions
|
||||||
module StopTime::Helpers
|
module StopTime::Mab
|
||||||
SUPPORTED = [:get, :post]
|
SUPPORTED = [:get, :post]
|
||||||
|
|
||||||
# Adds a method override field in form tags for (usually) unsupported
|
# # Adds a method override field in form tags for (usually) unsupported
|
||||||
# methods by browsers (i.e. PUT and DELETE) by injecting a hidden field.
|
# # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field.
|
||||||
def tag!(tag, *attrs)
|
# def tag!(tag, *attrs)
|
||||||
return super unless tag == :form && block_given?
|
# return super unless tag == :form && block_given?
|
||||||
attrs = attrs.last.is_a?(Hash) ? attrs.last : {}
|
# attrs = attrs.last.is_a?(Hash) ? attrs.last : {}
|
||||||
meth = attrs[:method]
|
# meth = attrs[:method]
|
||||||
attrs[:method] = 'post' if override = !SUPPORTED.include?(meth)
|
# attrs[:method] = 'post' if override = !SUPPORTED.include?(meth)
|
||||||
super(tag, attrs) do
|
# super(tag, attrs) do
|
||||||
input :type => 'hidden', :name => '_method', :value => meth if override
|
# input :type => 'hidden', :name => '_method', :value => meth if override
|
||||||
yield
|
# yield
|
||||||
end
|
# 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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue