mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
remove strange else block
This commit is contained in:
parent
ca59ec354e
commit
19c144f1b3
1 changed files with 7 additions and 9 deletions
|
@ -144,17 +144,15 @@ module ActionView
|
|||
options.reverse_merge!(:radius => 100, :omission => "...")
|
||||
|
||||
phrase = Regexp.escape(phrase)
|
||||
if found_pos = text.mb_chars =~ /(#{phrase})/i
|
||||
start_pos = [ found_pos - options[:radius], 0 ].max
|
||||
end_pos = [ [ found_pos + phrase.mb_chars.length + options[:radius] - 1, 0].max, text.mb_chars.length ].min
|
||||
return unless found_pos = text.mb_chars =~ /(#{phrase})/i
|
||||
|
||||
prefix = start_pos > 0 ? options[:omission] : ""
|
||||
postfix = end_pos < text.mb_chars.length - 1 ? options[:omission] : ""
|
||||
start_pos = [ found_pos - options[:radius], 0 ].max
|
||||
end_pos = [ [ found_pos + phrase.mb_chars.length + options[:radius] - 1, 0].max, text.mb_chars.length ].min
|
||||
|
||||
prefix + text.mb_chars[start_pos..end_pos].strip + postfix
|
||||
else
|
||||
nil
|
||||
end
|
||||
prefix = start_pos > 0 ? options[:omission] : ""
|
||||
postfix = end_pos < text.mb_chars.length - 1 ? options[:omission] : ""
|
||||
|
||||
prefix + text.mb_chars[start_pos..end_pos].strip + postfix
|
||||
end
|
||||
|
||||
# Attempts to pluralize the +singular+ word unless +count+ is 1. If
|
||||
|
|
Loading…
Reference in a new issue