Module: Refinery::HtmlTruncationHelper
- Defined in:
- app/helpers/refinery/html_truncation_helper.rb
Instance Method Summary collapse
-
#truncate(text, options = {}) ⇒ Object
Like the Rails truncate helper but doesn’t break HTML tags, entities, and words.
Instance Method Details
#truncate(text, options = {}) ⇒ Object
Like the Rails truncate helper but doesn’t break HTML tags, entities, and words. <script> tags pass through and are not counted in the total. the omission specified does count toward the total length count. use :link => link_to(‘more’, post_path), or something to that effect
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/refinery/html_truncation_helper.rb', line 10 def truncate(text, = {}) return unless text.present? return super unless .delete(:preserve_html_tags) == true # ensure preserve_html_tags doesn't pass through max_length = [:length] || 30 omission = [:omission] || "..." return truncate_html(text, :length => max_length, :word_boundary => true, :omission => omission) end |