Port the Markaby method override support to Mab

This commit is contained in:
Paul van Tilburg 2012-01-30 13:57:51 +01:00
parent 3c62004056
commit f1b5f5168b
1 changed files with 17 additions and 14 deletions

View File

@ -77,21 +77,24 @@ end
# = The Stop… Camping Time! Markaby extensions # = The Stop… Camping Time! Markaby extensions
# FIXME: update for Mab! # FIXME: update for Mab!
module StopTime::Helpers module StopTime::Mab
#SUPPORTED = [:get, :post] SUPPORTED = [:get, :post]
# # Adds a method override field in form tags for (usually) unsupported def mab_done(tag)
# # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. return super unless tag.name == :form
# def tag!(tag, *attrs)
# return super unless tag == :form && block_given? meth = tag.attributes[:method]
# attrs = attrs.last.is_a?(Hash) ? attrs.last : {} tag.attributes[:method] = 'post' if override = !SUPPORTED.include?(meth)
# meth = attrs[:method] # Inject a hidden input element with the proper method to the tag block
# attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) # if the form method is unsupported.
# super(tag, attrs) do orig_blk = tag.block
# input :type => 'hidden', :name => '_method', :value => meth if override tag.block = proc do
# yield input :type => 'hidden', :name => '_method', :value => meth
# end orig_blk.call
# end end if override
end
include Mab::Indentation
end end