Permalink
Browse files

remove private method and rewrite into more precise notation

  • Loading branch information...
1 parent ca1b98a commit e447ed6902e0134128728db7baaa48cdf74dc788 @prikha prikha committed Mar 4, 2014
Showing with 12 additions and 12 deletions.
  1. +12 −12 actionview/lib/action_view/helpers/form_tag_helper.rb
View
24 actionview/lib/action_view/helpers/form_tag_helper.rb
@@ -469,14 +469,22 @@ def submit_tag(value = "Save changes", options = {})
# # => <button data-disable-with="Please wait..." name="button" type="submit">Checkout</button>
#
def button_tag(content_or_options = nil, options = nil, &block)
+ default_options = { 'name' => 'button', 'type' => 'submit' }
- if content_or_options.is_a?(Hash)
+ if content_or_options.is_a? Hash
options = content_or_options
- content_or_options = nil
+ else
+ options ||= {}
end
- options = button_tag_options_with_defaults(options)
- content_tag :button, content_or_options || 'Button', options, &block
+ options = options.stringify_keys
+ options = options.reverse_merge default_options
+
+ if block_given?
+ content_tag :button, options, &block
+ else
+ content_tag :button, content_or_options || 'Button', options
+ end
end
# Displays an image which when clicked will submit the form.
@@ -742,14 +750,6 @@ def form_tag_in_block(html_options, &block)
def sanitize_to_id(name)
name.to_s.delete(']').gsub(/[^-a-zA-Z0-9:.]/, "_")
end
-
- def button_tag_options_with_defaults(options)
- options = options || {}
- options = options.stringify_keys
-
- default_options = { 'name' => 'button', 'type' => 'submit' }
- options.reverse_merge default_options
- end
end
end
end

0 comments on commit e447ed6

Please sign in to comment.