Method: Decidim::ApplicationHelper#html_truncate
- Defined in:
- decidim-core/app/helpers/decidim/application_helper.rb
#html_truncate(text, options = {}) ⇒ Object
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 is being
truncated.
Returns a String.
25 26 27 28 29 30 31 32 33 |
# File 'decidim-core/app/helpers/decidim/application_helper.rb', line 25 def html_truncate(text, = {}) [:max_length] = .delete(:length) || [:max_length] [:tail] = .delete(:separator) || [:tail] || "…" [:count_tags] ||= false [:count_tail] ||= false [:tail_before_final_tag] = true unless .has_key?(:tail_before_final_tag) Decidim::HtmlTruncation.new(text, ).perform end |