Module: Yarrow::HTML::AssetTags
Instance Method Summary collapse
-
#base_url_path ⇒ Object
Computes the base URL path to assets in the public web directory.
- #link_tag(options) ⇒ Object
-
#manifest ⇒ Object
TODO: make sprockets manifest optional/pluggable.
- #script_tag(options) ⇒ Object
- #script_tags ⇒ Object
Methods included from Configurable
Instance Method Details
#base_url_path ⇒ Object
Computes the base URL path to assets in the public web directory.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/yarrow/html/asset_tags.rb', line 13 def base_url_path if config.assets.nil? || config.output_dir.nil? raise Yarrow::ConfigurationError end # TODO: prepend configurable CDN URL for host path # TODO: dev/production mode switch config.assets.output_dir.gsub(config.output_dir, '') end |
#link_tag(options) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/yarrow/html/asset_tags.rb', line 38 def link_tag() href_path = if asset_in_manifest?() digest_path([:asset]) else [:href] end "<link href=\"#{href_path}\" rel=\"stylesheet\" type=\"text/css\">" end |
#manifest ⇒ Object
TODO: make sprockets manifest optional/pluggable
7 8 9 |
# File 'lib/yarrow/html/asset_tags.rb', line 7 def manifest Yarrow::Assets::Manifest.new(config) end |
#script_tag(options) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/yarrow/html/asset_tags.rb', line 28 def script_tag() src_path = if asset_in_manifest?() digest_path([:asset]) else [:src] end "<script src=\"#{src_path}\"></script>" end |
#script_tags ⇒ Object
24 25 26 |
# File 'lib/yarrow/html/asset_tags.rb', line 24 def manifest.js_logical_paths.map { |path| script_tag(asset: path) }.join("\n") end |