diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-05-17 14:05:31 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-05-17 14:05:31 -0700 |
commit | b23ac936a6ef980547666da002681a77d8340573 (patch) | |
tree | e3f4a00f633b0aa915941b8e970667feeb781901 /actionpack/lib | |
parent | 598fc201f9a023828d7e8777e24e0a66f01c7ff2 (diff) | |
parent | 90ec863b1d62bade591e841efbb7120bcbe94031 (diff) | |
download | rails-b23ac936a6ef980547666da002681a77d8340573.tar.gz rails-b23ac936a6ef980547666da002681a77d8340573.tar.bz2 rails-b23ac936a6ef980547666da002681a77d8340573.zip |
Merge pull request #6371 from ihid/remove_old_text_helper_api
Removed old text_helper apis for highlight, excerpt and word_wrap
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/text_helper.rb | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 67117077dc..da8c0d1de6 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -101,17 +101,7 @@ module ActionView # # highlight('You searched for: rails', 'rails', :highlighter => '<a href="search?q=\1">\1</a>') # # => You searched for: <a href="search?q=rails">rails</a> - # - # You can still use <tt>highlight</tt> with the old API that accepts the - # +highlighter+ as its optional third parameter: - # - # highlight('You searched for: rails', 'rails', '<a href="search?q=\1">\1</a>') - # # => You searched for: <a href="search?q=rails">rails</a> - def highlight(text, phrases, *args) - options = args.extract_options! - unless args.empty? - options[:highlighter] = args[0] - end + def highlight(text, phrases, options = {}) options[:highlighter] ||= '<mark>\1</mark>' text = sanitize(text) unless options[:sanitize] == false @@ -143,20 +133,8 @@ module ActionView # # excerpt('This is also an example', 'an', :radius => 8, :omission => '<chop> ') # # => <chop> is also an example - # - # You can still use <tt>excerpt</tt> with the old API that accepts the - # +radius+ as its optional third and the +ellipsis+ as its - # optional forth parameter: - # excerpt('This is an example', 'an', 5) # => ...s is an exam... - # excerpt('This is also an example', 'an', 8, '<chop> ') # => <chop> is also an example - def excerpt(text, phrase, *args) + def excerpt(text, phrase, options = {}) return unless text && phrase - - options = args.extract_options! - unless args.empty? - options[:radius] = args[0] - options[:omission] = args[1] - end radius = options[:radius] || 100 omission = options[:omission] || "..." @@ -206,17 +184,7 @@ module ActionView # # word_wrap('Once upon a time', :line_width => 1) # # => Once\nupon\na\ntime - # - # You can still use <tt>word_wrap</tt> with the old API that accepts the - # +line_width+ as its optional second parameter: - # - # word_wrap('Once upon a time', 8) - # # => Once\nupon a\ntime - def word_wrap(text, *args) - options = args.extract_options! - unless args.blank? - options[:line_width] = args[0] - end + def word_wrap(text, options = {}) line_width = options[:line_width] || 80 text.split("\n").collect do |line| |