Sha256: 8812e3c633b4459920c8a326eae50a9f06e369d14f433802fcc6070803336c79

Contents?: true

Size: 1.34 KB

Versions: 35

Compression:

Stored size: 1.34 KB

Contents

module Helpers
    module ThecoreUiCommonsHelper
        def get_asset_tags_for(basename)
            out = []

            # Needs to reverse since Paths are traversed in the order they occur in the search path. By default, this means the files in app/assets take precedence, and will mask corresponding paths in lib and vendor.
            Rails.application.config.assets.paths.reverse.each do |basedir|
                base = "#{basedir}/**/#{basename}"
                base_s = Dir["#{base}.{css,scss}"]
                base_j = Dir["#{base}.js"]
                
                (out << stylesheet_link_tag("#{get_folder base_s}/#{basename}", media: 'all', 'data-turbolinks-track' => true) if base_s.any?) rescue nil
                (out << javascript_include_tag("#{get_folder base_j}/#{basename}", 'data-turbolinks-track' => true) if base_j.any?) rescue nil
            end

            # Application level assets
            (out << stylesheet_link_tag('application', media: 'all', 'data-turbolinks-track' => true)) rescue nil
            (out << javascript_include_tag('application', 'data-turbolinks-track' => true)) rescue nil

            out.join("\n").html_safe
        end
        
        def get_folder(base)
            base.first.split("/")[-2]
        end
    end
end

ActiveSupport.on_load(:action_view) { include Helpers::ThecoreUiCommonsHelper }

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
thecore_ui_commons-2.5.2 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.5.1 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.5.0 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.4.10 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.4.9 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.4.8 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.4.7 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.4.6 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.4.5 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.4.4 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.4.3 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.4.2 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.4.1 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.4.0 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.3.10 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.3.9 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.3.8 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.3.7 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.3.6 config/initializers/thecore_ui_commons_helper.rb
thecore_ui_commons-2.3.5 config/initializers/thecore_ui_commons_helper.rb