Sha256: 6a17b72bef1a7b3396e053cdf897971fe6c678b1d6015991ae15ae97f87a6014

Contents?: true

Size: 967 Bytes

Versions: 72

Compression:

Stored size: 967 Bytes

Contents

module Udongo
  module Assets
    class Loader
      attr_reader :files
      attr_accessor :view

      def initialize
        @files = []
      end

      def add(file)
        file = file.split('.js').first if file.include?('.js')
        file = file.split('.scss').first if file.include?('.scss')
        file = file.split('.css').first if file.include?('.css')
        @files.push file
      end

      def exists?(file)
        @files.include?(file)
      end

      def load_css(file, media = :screen)
        load_file(file, :stylesheets) { @view.stylesheet_link_tag(file, media: media) }
      end

      def load_file(file, target, &block)
        if block_given? && !exists?(file)
          add file
          @view.content_for(target) { yield file }
          return true
        end
        false
      end

      def load_js(file, target = :javascripts)
        load_file(file, target) { @view.javascript_include_tag(file) }
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
udongo-7.9.0 lib/udongo/assets/loader.rb
udongo-7.8.1 lib/udongo/assets/loader.rb
udongo-7.8.0 lib/udongo/assets/loader.rb
udongo-7.7.2 lib/udongo/assets/loader.rb
udongo-7.7.1 lib/udongo/assets/loader.rb
udongo-7.7.0 lib/udongo/assets/loader.rb
udongo-7.6.2 lib/udongo/assets/loader.rb
udongo-7.6.1 lib/udongo/assets/loader.rb
udongo-7.6.0 lib/udongo/assets/loader.rb
udongo-7.5.1 lib/udongo/assets/loader.rb
udongo-7.5.0 lib/udongo/assets/loader.rb
udongo-7.4.2 lib/udongo/assets/loader.rb
udongo-7.4.1 lib/udongo/assets/loader.rb
udongo-7.4.0 lib/udongo/assets/loader.rb
udongo-7.3.5 lib/udongo/assets/loader.rb
udongo-7.3.4 lib/udongo/assets/loader.rb
udongo-7.3.3 lib/udongo/assets/loader.rb
udongo-7.3.2 lib/udongo/assets/loader.rb
udongo-7.3.1 lib/udongo/assets/loader.rb
udongo-7.2.1 lib/udongo/assets/loader.rb