Module: LibraryHelper
- Included in:
- Library::LibraryTags
- Defined in:
- app/helpers/library_helper.rb
Instance Method Summary collapse
- #clean_html(text) ⇒ Object
- #strip_html(text) ⇒ Object
- #truncate_words(text = '', options = {}) ⇒ Object
Instance Method Details
#clean_html(text) ⇒ Object
5 6 7 |
# File 'app/helpers/library_helper.rb', line 5 def clean_html(text) Sanitize.clean(text, Sanitize::Config::RELAXED) end |
#strip_html(text) ⇒ Object
9 10 11 |
# File 'app/helpers/library_helper.rb', line 9 def strip_html(text) Sanitize.clean(text) end |
#truncate_words(text = '', options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/library_helper.rb', line 13 def truncate_words(text='', ={}) return '' if text.blank? ellipsis = [:ellipsis] || '…' limit = ([:limit] || 64).to_i text = strip_html(text) if [:strip] words = text.split ellipsis = '' unless words.size > limit words[0..(limit-1)].join(" ") + ellipsis end |