Module: Decidim::ApplicationHelper
- Includes:
- OmniauthHelper
- Defined in:
- app/helpers/decidim/application_helper.rb
Overview
Main module to add application-wide helpers.
Instance Method Summary collapse
-
#html_truncate(text, options = {}) ⇒ Object
Truncates a given text respecting its HTML tags.
Methods included from OmniauthHelper
#any_social_provider_enabled?, #normalize_provider_name, #social_provider_enabled?
Instance Method Details
#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's being
truncated. See `truncato` gem for more options.
Returns a String.
17 18 19 20 21 22 23 24 25 |
# File 'app/helpers/decidim/application_helper.rb', line 17 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 Truncato.truncate(text, ) end |