Sha256: 47eafba30b3b6312e07bd1c422fa9ca2557d8fbf5e491098a9b2d320e9e2be3d
Contents?: true
Size: 971 Bytes
Versions: 9
Compression:
Stored size: 971 Bytes
Contents
require_dependency 'truncate_html' module Refinery module Helpers module 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 end end
Version data entries
9 entries across 9 versions & 1 rubygems