Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use present, not nil for truncate helper

  • Loading branch information...
commit 4235e60e4b1d3ccc3ff8a553cbb4f7a7b7ce3cc6 1 parent de9a723
@sudara authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  app/helpers/application_helper.rb
View
2  app/helpers/application_helper.rb
@@ -54,7 +54,7 @@ def track_name_for(asset, length=40)
# in the middle of an entity ex.: truncate("this & that",9) => "this &am..."
# though it will not be the exact length.
def awesome_truncate(text, length = 30, truncate_string = "...")
- return if text.nil?
+ return unless text.present?
l = length - truncate_string.mb_chars.length
text.mb_chars.length > length ? text[/\A.{#{l}}\w*\;?/m][/.*[\w\;]/m] + truncate_string : text
end
Please sign in to comment.
Something went wrong with that request. Please try again.