Module: WeasyPDF::ViewHelpers::ViteAssets
- Defined in:
- lib/weasy_pdf/view_helpers/vite_assets.rb
Overview
Included on top of Assets when vite_ruby is available. Overrides asset resolution to use ViteRuby’s manifest.
Instance Method Summary collapse
-
#weasy_pdf_asset_path(asset) ⇒ Object
weasy_pdf_image_tag is inherited from Assets — it calls weasy_pdf_asset_path, which IS overridden here, so override-by-dispatch is enough.
- #weasy_pdf_stylesheet_link_tag(*sources) ⇒ Object
Instance Method Details
#weasy_pdf_asset_path(asset) ⇒ Object
weasy_pdf_image_tag is inherited from Assets — it calls weasy_pdf_asset_path, which IS overridden here, so override-by-dispatch is enough. No re-definition needed.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/weasy_pdf/view_helpers/vite_assets.rb', line 17 def weasy_pdf_asset_path(asset) return asset if asset.to_s.start_with?("http://", "https://", "data:", "//") url = vite_asset_url(asset) if cdn_url?(url) url elsif vite_dev_server_running? content = fetch_bytes(url) "data:#{mime_for(asset)};base64,#{Base64.strict_encode64(content)}" else disk = disk_path_from_url(url) (disk && File.exist?(disk.to_s)) ? "file://#{disk}" : url end end |
#weasy_pdf_stylesheet_link_tag(*sources) ⇒ Object
10 11 12 |
# File 'lib/weasy_pdf/view_helpers/vite_assets.rb', line 10 def weasy_pdf_stylesheet_link_tag(*sources) sources.map { |source| resolve_vite_stylesheet(source) }.join("\n").html_safe end |