Sha256: 2237f18e4bbd8f4d6ef6bfcfa1498cfd9b3f4d3341a94f976fe45010b952e269

Contents?: true

Size: 870 Bytes

Versions: 16

Compression:

Stored size: 870 Bytes

Contents

require_dependency 'truncate_html'

module Refinery::HtmlTruncationHelper

  # 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
  def truncate(text, *args)
    return unless text.present?
    return super unless ((arguments = args.dup).extract_options![:preserve_html_tags] == true) # don't ruin the current args object

    options = args.extract_options!
    max_length = options[:length] || 30
    omission = options[:omission] || "..."

    return truncate_html(text,
                         :length => max_length,
                         :word_boundary => true,
                         :omission => omission)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
refinerycms-0.9.7.15 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.14 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.8 vendor/refinerycms/core/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.13 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.11 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.10 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.9 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.8 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.7 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.6 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.5 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.4 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.3 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.2 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7.1 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
refinerycms-0.9.7 vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb