Module: Graspi::AssetsIncludeHelper

Defined in:
lib/graspi/helpers/assets_include_helper.rb

Instance Method Summary collapse

Instance Method Details

#graspi_file_path(path) ⇒ Object



38
39
40
41
42
# File 'lib/graspi/helpers/assets_include_helper.rb', line 38

def graspi_file_path(path)
  mapping = Graspi.manifest(Rails.env)

  mapping[path]
end

#graspi_image_tag(path, options = {}) ⇒ Object



32
33
34
35
36
# File 'lib/graspi/helpers/assets_include_helper.rb', line 32

def graspi_image_tag(path, options = {})
  tag_options = options.merge({ src: graspi_file_path(path) })

  tag(:img, tag_options)
end

#graspi_image_url(path) ⇒ Object



28
29
30
# File 'lib/graspi/helpers/assets_include_helper.rb', line 28

def graspi_image_url(path)
  graspi_file_path(path)
end

#graspi_javascript_include_tag(*sources) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/graspi/helpers/assets_include_helper.rb', line 17

def graspi_javascript_include_tag(*sources)
  options = sources.extract_options!.stringify_keys

  sources.uniq.map { |source|
    tag_options = {
      "src" => graspi_file_path("#{source}.js")
    }.merge!(options)
    (:script, "", tag_options)
  }.join("\n").html_safe
end


4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/graspi/helpers/assets_include_helper.rb', line 4

def graspi_stylesheet_link_tag(*sources)
  options = sources.extract_options!.stringify_keys

  sources.uniq.map { |source|
    tag_options = {
      "rel" => "stylesheet",
      "media" => "screen",
      "href" => graspi_file_path("#{source}.css")
    }.merge!(options)
    tag(:link, tag_options)
  }.join("\n").html_safe
end