Module: ActionView::Helpers::AssetTagHelper

Defined in:
lib/initializers/sprockets_helper.rb

Instance Method Summary collapse

Instance Method Details

#javascript_include_tag_with_sprockets(*sources) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/initializers/sprockets_helper.rb', line 8

def javascript_include_tag_with_sprockets(*sources)
  sprocketized_sources = sources.map do |source|
    source = source.gsub(/^\/assets\//, "")
    source = source.gsub(/\.js$/, "")
    if source.kind_of? String and !Assets[source].nil?
      digest = Assets[source].digest
      "/assets/#{source}.js?#{digest}"
    else
      source
    end
  end
  javascript_include_tag_without_sprockets(*sprocketized_sources)
end