Class: Bridgetown::Tags::AssetPath
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Bridgetown::Tags::AssetPath
- Defined in:
- bridgetown-core/lib/bridgetown-core/tags/asset_path.rb
Overview
A helper class to help find the path to assets inside of an esbuild manifest file.
Instance Method Summary collapse
-
#initialize(tag_name, asset_type, options) ⇒ void
constructor
-
#render(context) ⇒ String
Render an asset path based on the frontend manifest file.
Constructor Details
#initialize(tag_name, asset_type, options) ⇒ void
13 14 15 16 17 18 |
# File 'bridgetown-core/lib/bridgetown-core/tags/asset_path.rb', line 13 def initialize(tag_name, asset_type, ) super # js or css @asset_type = asset_type.strip end |
Instance Method Details
#render(context) ⇒ String
Render an asset path based on the frontend manifest file
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'bridgetown-core/lib/bridgetown-core/tags/asset_path.rb', line 27 def render(context) @context = context site = context.registers[:site] if tag_name == "webpack_path" source_file = "#{context.registers.static[:file_system].root.last}/#{context.template_name}.liquid" raise( Bridgetown::Errors::FatalException, "🚨 Oops, you'll need to change `webpack_path' to `asset_path' in:\n#{source_file}\n" ) end Bridgetown::Utils.parse_frontend_manifest_file(site, @asset_type) || "" end |