diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-16 05:42:47 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-16 05:42:47 +0000 |
commit | 691562746f277aa0453ec9fdc06fad5a59210fb5 (patch) | |
tree | 356af3e5c49511d7cb40d5f4d855249e5a3cb3e0 /actionpack/lib/action_view | |
parent | bfe6a759c25ad02b4bfcb2dd16999d8ba72e2df8 (diff) | |
download | rails-691562746f277aa0453ec9fdc06fad5a59210fb5.tar.gz rails-691562746f277aa0453ec9fdc06fad5a59210fb5.tar.bz2 rails-691562746f277aa0453ec9fdc06fad5a59210fb5.zip |
Fixed TextHelper#highlight to return the text, not nil, if the phrase is blank #1409 [patrick@lenz.sh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1429 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/text_helper.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 2cc4b68ec0..0abd8e79fa 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -26,7 +26,7 @@ module ActionView # passing +highlighter+ as single-quoted string with \1 where the phrase is supposed to be inserted. # N.B.: The +phrase+ is sanitized to include only letters, digits, and spaces before use. def highlight(text, phrase, highlighter = '<strong class="highlight">\1</strong>') - if text.nil? || phrase.nil? then return end + if phrase.blank? then return text end text.gsub(/(#{escape_regexp(phrase)})/i, highlighter) unless text.nil? end |