Module: SewingKit::Webpack::Helper
- Defined in:
- lib/sewing_kit/webpack/helper.rb
Defined Under Namespace
Classes: Asset, UnknownAssetError
Instance Method Summary
collapse
Instance Method Details
#sewing_kit_assets(entrypoint_name, extension: "js") ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/sewing_kit/webpack/helper.rb', line 14
def sewing_kit_assets(entrypoint_name, extension: "js")
return "" unless entrypoint_name.present?
assets = SewingKit::Webpack::Manifest.asset_dependencies(entrypoint_name, request.user_agent)
raise UnknownAssetError, "#{entrypoint_name} was not found in manifest." if raise_unknown_error?(assets)
return [] unless assets && assets[extension]
dependencies = assets[extension]
dependencies.map do |raw_asset|
Asset.new(raw_asset["path"], raw_asset["integrity"])
end
end
|
#sewing_kit_assets_bundle_name ⇒ Object
#sewing_kit_link_tag(*assets) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/sewing_kit/webpack/helper.rb', line 28
def sewing_kit_link_tag(*assets)
options = assets.
tags = assets.uniq.map do |asset|
next "" if asset.path == ""
create_asset_tag(:link, asset, options)
end
safe_join(tags, "\n")
end
|
#sewing_kit_script_tag(*assets) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/sewing_kit/webpack/helper.rb', line 40
def sewing_kit_script_tag(*assets)
options = assets.
tags = assets.map do |asset|
next "" if asset.path == ""
create_asset_tag(:script, asset, options)
end
safe_join(tags, "\n")
end
|