Module: Sprockets::Rails::Helper

Defined in:
lib/emcee/helpers/sprockets_helper.rb

Instance Method Summary collapse

Instance Method Details

#html_import_tag(*sources) ⇒ Object

Custom view helper used to create an html import. This same method is already defined in ActionView. We pull out the sources here, before calling back to ActionView’s.

Based on Sprocket’s javascript_include_tag.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/emcee/helpers/sprockets_helper.rb', line 9

def html_import_tag(*sources)
  options = sources.extract_options!.stringify_keys
  if options["debug"] != false && request_debug_assets?
    sources.map { |source|
      #check_errors_for(source)
      if asset = lookup_asset_for_path(source, type: :html)
        asset.to_a.map do |a|
          super(path_to_html(a.logical_path, debug: true), options)
        end
      else
        super(source, options)
      end
    }.flatten.uniq.join("\n").html_safe
  else
    sources.push(options)
    super(*sources)
  end
end