From 90ec863b1d62bade591e841efbb7120bcbe94031 Mon Sep 17 00:00:00 2001 From: Jeremy Walker Date: Thu, 17 May 2012 21:52:49 +0100 Subject: Removed old text_helper apis for highlight, excerpt and word_wrap --- actionpack/lib/action_view/helpers/text_helper.rb | 38 ++--------------------- 1 file changed, 3 insertions(+), 35 deletions(-) (limited to 'actionpack/lib') 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 => '\1') # # => You searched for: rails - # - # You can still use highlight with the old API that accepts the - # +highlighter+ as its optional third parameter: - # - # highlight('You searched for: rails', 'rails', '\1') - # # => You searched for: rails - def highlight(text, phrases, *args) - options = args.extract_options! - unless args.empty? - options[:highlighter] = args[0] - end + def highlight(text, phrases, options = {}) options[:highlighter] ||= '\1' text = sanitize(text) unless options[:sanitize] == false @@ -143,20 +133,8 @@ module ActionView # # excerpt('This is also an example', 'an', :radius => 8, :omission => ' ') # # => is also an example - # - # You can still use excerpt 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, ' ') # => 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 word_wrap 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| -- cgit v1.2.3