module Webpacked::Helper

Add new view helpers

Public Instance Methods

asset_tag(entry, kind) click to toggle source

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

# File lib/webpacked/helper.rb, line 30
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) click to toggle source

Alias for Webpacked::Manifest.asset_paths

# File lib/webpacked/helper.rb, line 41
def webpacked_asset_path(entry, kind = nil)
  Webpacked::Manifest.asset_paths(entry, kind)
end
webpacked_css_tags(entries) click to toggle source

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

# File lib/webpacked/helper.rb, line 12
def webpacked_css_tags(entries)
  webpacked_tags entries, :css
end
webpacked_js_tags(entries) click to toggle source

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

# File lib/webpacked/helper.rb, line 6
def webpacked_js_tags(entries)
  webpacked_tags entries, :js
end
webpacked_tags(entries, kind) click to toggle source

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

# File lib/webpacked/helper.rb, line 18
def webpacked_tags(entries, kind)
  common_entry = ::Rails.configuration.webpacked.common_entry_name
  common_bundle = asset_tag(common_entry, kind)
  page_bundle = Array(entries).reduce('') do |memo, entry|
    tag = asset_tag(entry, kind)
    memo << tag if tag
  end
  common_bundle ? [common_bundle, page_bundle].join : page_bundle
end