Sha256: b0d44fc15ef3be47585f06b5f5d7eab88cc5d30a0e1640f25bb93d767452c7cc

Contents?: true

Size: 1001 Bytes

Versions: 32

Compression:

Stored size: 1001 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Main module to add application-wide helpers.
  module ApplicationHelper
    include Decidim::OmniauthHelper
    include Decidim::ScopesHelper

    # 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
      options[:tail_before_final_tag] ||= true

      Truncato.truncate(text, options)
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
decidim-core-0.8.4 app/helpers/decidim/application_helper.rb
decidim-core-0.8.3 app/helpers/decidim/application_helper.rb
decidim-core-0.8.2 app/helpers/decidim/application_helper.rb
decidim-core-0.8.1 app/helpers/decidim/application_helper.rb
decidim-core-0.8.0 app/helpers/decidim/application_helper.rb
decidim-core-0.7.4 app/helpers/decidim/application_helper.rb
decidim-core-0.7.3 app/helpers/decidim/application_helper.rb
decidim-core-0.7.2 app/helpers/decidim/application_helper.rb
decidim-core-0.7.1 app/helpers/decidim/application_helper.rb
decidim-core-0.7.0 app/helpers/decidim/application_helper.rb
decidim-core-0.6.8 app/helpers/decidim/application_helper.rb
decidim-0.6.8 decidim-core/app/helpers/decidim/application_helper.rb
decidim-core-0.6.7 app/helpers/decidim/application_helper.rb
decidim-0.6.7 decidim-core/app/helpers/decidim/application_helper.rb
decidim-core-0.6.6 app/helpers/decidim/application_helper.rb
decidim-0.6.6 decidim-core/app/helpers/decidim/application_helper.rb
decidim-core-0.6.5 app/helpers/decidim/application_helper.rb
decidim-0.6.5 decidim-core/app/helpers/decidim/application_helper.rb
decidim-core-0.6.4 app/helpers/decidim/application_helper.rb
decidim-0.6.4 decidim-core/app/helpers/decidim/application_helper.rb