Module: Webpacked::Helper

Defined in:
lib/webpacked/helper.rb

Overview

Add new view helpers

Instance Method Summary collapse

Instance Method Details

#asset_tag(entry, kind) ⇒ Object

Return include tags for entry point by given asset kind. No extra common file included even if it exists



27
28
29
30
31
32
33
34
35
# File 'lib/webpacked/helper.rb', line 27

def asset_tag(entry, kind)
  path = webpacked_asset_path(entry, kind)
  if path
    case kind
    when :js  then javascript_include_tag path
    when :css then stylesheet_link_tag    path
    end
  end
end

#webpacked_asset_path(entry, kind = nil) ⇒ Object

Alias for Webpacked::Manifest.asset_paths



38
39
40
# File 'lib/webpacked/helper.rb', line 38

def webpacked_asset_path(entry, kind = nil)
  Webpacked::Manifest.asset_paths(entry, kind)
end

#webpacked_css_tags(entry) ⇒ Object

Return stylesheet_link_tag for entry point. Also common CSS file could be included



12
13
14
# File 'lib/webpacked/helper.rb', line 12

def webpacked_css_tags(entry)
  webpacked_tags entry, :css
end

#webpacked_js_tags(entry) ⇒ Object

Return javascript_include_tag for entry point. Also common Javascript file could be included



6
7
8
# File 'lib/webpacked/helper.rb', line 6

def webpacked_js_tags(entry)
  webpacked_tags entry, :js
end

#webpacked_tags(entry, kind) ⇒ Object

Return include tags for entry point by given asset kind. Also common file could be included



18
19
20
21
22
23
# File 'lib/webpacked/helper.rb', line 18

def webpacked_tags(entry, kind)
  common_entry = ::Rails.configuration.webpacked.common_entry_name
  common_bundle = asset_tag(common_entry, kind)
  page_bundle   = asset_tag(entry, kind)
  common_bundle ? common_bundle + page_bundle : page_bundle
end