Skip to content
Browse files

modify haml text_area

  • Loading branch information...
1 parent 0535248 commit 7c4329dba5cef9a4c6d9f1e0e17e7f91756c9b41 @amesel amesel committed
Showing with 26 additions and 0 deletions.
  1. +26 −0 config/initializers/haml_text_area.rb
View
26 config/initializers/haml_text_area.rb
@@ -0,0 +1,26 @@
+module ActionView
+ module Helpers
+ module FormHelper
+ def text_area(object_name, method, options = {})
+ html = InstanceTag.new(object_name, method, self, options.delete(:object)).to_text_area_tag(options)
+ html.sub(/>\
/, '>').html_safe
+ end
+ end
+
+ module FormTagHelper
+ def text_area_tag(name, content = nil, options = {})
+ options = options.stringify_keys
+
+ if size = options.delete("size")
+ options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
+ end
+
+ escape = options.key?("escape") ? options.delete("escape") : true
+ content = ERB::Util.html_escape(content) if escape
+
+ html = content_tag :textarea, content.to_s.html_safe, { "name" => name, "id" => sanitize_to_id(name) }.update(options)
+ html.sub(/>\
/, '>').html_safe
+ end
+ end
+ end
+end

0 comments on commit 7c4329d

Please sign in to comment.
Something went wrong with that request. Please try again.