diff options
author | Paul Nikitochkin <paul.nikitochkin@gmail.com> | 2013-07-25 23:56:26 +0300 |
---|---|---|
committer | Paul Nikitochkin <paul.nikitochkin@gmail.com> | 2013-09-06 18:00:55 +0300 |
commit | 061e48df26557bb0a667794df9772880846058cb (patch) | |
tree | 328b5eec47d1c86ec7999ea85a7bc75ce20cfbbe /actionview/lib/action_view/helpers | |
parent | b77781c012ebb60bfeee114aef6597ab8d3d3016 (diff) | |
download | rails-061e48df26557bb0a667794df9772880846058cb.tar.gz rails-061e48df26557bb0a667794df9772880846058cb.tar.bz2 rails-061e48df26557bb0a667794df9772880846058cb.zip |
Cleanup of excerpt helper
* replaced String concatenation by joining
* separator has default value to '', even it is nil
Diffstat (limited to 'actionview/lib/action_view/helpers')
-rw-r--r-- | actionview/lib/action_view/helpers/text_helper.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/actionview/lib/action_view/helpers/text_helper.rb b/actionview/lib/action_view/helpers/text_helper.rb index 3fc64fa8a5..c23d605c5f 100644 --- a/actionview/lib/action_view/helpers/text_helper.rb +++ b/actionview/lib/action_view/helpers/text_helper.rb @@ -150,7 +150,7 @@ module ActionView def excerpt(text, phrase, options = {}) return unless text && phrase - separator = options.fetch(:separator, "") + separator = options[:separator] || '' phrase = Regexp.escape(phrase) regex = /#{phrase}/i @@ -171,7 +171,8 @@ module ActionView prefix, first_part = cut_excerpt_part(:first, first_part, separator, options) postfix, second_part = cut_excerpt_part(:second, second_part, separator, options) - prefix + (first_part + separator + phrase + separator + second_part).strip + postfix + affix = [first_part, separator, phrase, separator, second_part].join.strip + [prefix, affix, postfix].join end # Attempts to pluralize the +singular+ word unless +count+ is 1. If |