Sha256: 3d3d41157209d9554ad5f8d1d4be64e2cd9322913528321bf3b582d1a1d5be67
Contents?: true
Size: 900 Bytes
Versions: 7
Compression:
Stored size: 900 Bytes
Contents
# encoding: utf-8 # frozen_string_literal: true module Decidim # Main module to add application-wide helpers. module ApplicationHelper # Truncates a given text respecting its HTML tags. # # text - The String text to be truncated. # options - A Hash with the options to truncate the text (default: {}): # :length - An Integer number with the max length of the text. # :separator - A String to append to the text when it's being # truncated. See `truncato` gem for more options. # # Returns a String. def html_truncate(text, options = {}) options[:max_length] = options.delete(:length) || options[:max_length] options[:tail] = options.delete(:separator) || options[:tail] || "..." options[:count_tags] ||= false options[:count_tail] ||= false Truncato.truncate(text, options) end end end
Version data entries
7 entries across 7 versions & 1 rubygems