Module: AssetsHelper

Defined in:
app/helpers/assets_helper.rb

Constant Summary collapse

VER =
Time.now.to_i.to_s

Instance Method Summary collapse

Instance Method Details

#assets(*opts) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/assets_helper.rb', line 8

def assets *opts
  return '' if opts.blank?
  html = ''
  opts.each do |name|
    name = name.to_s
    format = File.extname(name)
    if Rails.env.production? && !name.include?('.min.') && (format == '.css' || format == '.js')
      name = name.gsub(format, '.min' << format)
    end
    case format
      when '.css'
        html << assets_css(name)
      when '.js'
        html << assets_js(name)
      else
        path = Rails.root.to_s + '/app/assets/' + name
        css = Dir.glob(([:css] + AssetFormat::Css::EXTEND_FORMATS).map{ |f| path + '.' + f.to_s })
        js = Dir.glob(([:js] + AssetFormat::Js::EXTEND_FORMATS).map{ |f| path + '.' + f.to_s })
        html << assets(name + '.css') if css.length > 0
        html << assets(name + '.js') if js.length > 0
        html << assets_file(name) if css.length == 0 && js.length == 0
    end
  end
  html
end

#assets_versionObject



4
5
6
# File 'app/helpers/assets_helper.rb', line 4

def assets_version
  VER
end