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