aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorAvi Tzurel <avi@kensodev.com>2012-05-14 01:15:46 +0300
committerAvi Tzurel <avi@kensodev.com>2012-05-14 16:55:41 +0300
commit4bb14b0daafb9b1c3d0d5c041703c9242b27adc6 (patch)
tree8d7c7fffa6a8553d47e8a9bbe8f79eb313383c92 /actionpack/lib
parent09fcac95d7d263b054fa0c9a168da2789ce8ae06 (diff)
downloadrails-4bb14b0daafb9b1c3d0d5c041703c9242b27adc6.tar.gz
rails-4bb14b0daafb9b1c3d0d5c041703c9242b27adc6.tar.bz2
rails-4bb14b0daafb9b1c3d0d5c041703c9242b27adc6.zip
Added the wrapper tag option to simple_format
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 19ecb617a8..a62864bf81 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -241,6 +241,7 @@ module ActionView
#
# ==== Options
# * <tt>:sanitize</tt> - If +false+, does not sanitize +text+.
+ # * <tt>:wrapper_tag</tt> - String representing the tag wrapper, defaults to <tt>"p"</tt>
#
# ==== Examples
# my_text = "Here is some basic text...\n...with a line break."
@@ -260,13 +261,14 @@ module ActionView
# # => "<p><span>I'm allowed!</span> It's true.</p>"
def simple_format(text, html_options={}, options={})
text = sanitize(text) unless options[:sanitize] == false
+ wrapper_tag = options.fetch(:wrapper_tag, :p)
paragraphs = split_paragraphs(text)
if paragraphs.empty?
- content_tag('p', nil, html_options)
+ content_tag(wrapper_tag, nil, html_options)
else
paragraphs.map { |paragraph|
- content_tag('p', paragraph, html_options, options[:sanitize])
+ content_tag(wrapper_tag, paragraph, html_options, options[:sanitize])
}.join("\n\n").html_safe
end
end