Sha256: bb8ba7f2c6ac79df7e195b24a69521365f493a201cb1249d80114fd03817f3e0
Contents?: true
Size: 904 Bytes
Versions: 2
Compression:
Stored size: 904 Bytes
Contents
module DisplayHelper def scrap_word(text, char_count_limit, more_text = nil, more_link = nil,style='') # remove HTML tags text = text.to_s.gsub(/<\/?[^>]*>/, " ") # remove additional spaces text = text.to_s.gsub(/[ ]+/, " ") if text.length < char_count_limit return text end teaser = "" words = text.split(/ /) words.each do |word| if word.length > 0 if (teaser + word).length > char_count_limit if more_text && more_link teaser = teaser + " " + link_to(more_text, more_link,:style=>style, :target=>"_blank") else teaser = teaser.strip + "..." end break; else teaser = teaser + word + " " end end end return teaser end def display_time(disp_time, class_name="") return distance_of_time_in_words_to_now(disp_time) + " ago" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
humdrum-rails-0.1.3 | lib/rails/generators/humdrum/layout/templates/helpers/display_helper.rb |
humdrum-rails-0.1.2 | lib/rails/generators/humdrum/layout/templates/helpers/display_helper.rb |