module

BunBunBundle::Helpers

HTML helpers for rendering asset tags.

Include this module in your view/layout to get access to bun_asset, bun_js_tag, bun_css_tag, and bun_img_tag.

class MyLayout
  include BunBunBundle::Helpers

  def render(io)
    io << bun_css_tag("css/app.css")
    io << bun_js_tag("js/app.js")
  end
end

Constants

FINGERPRINTED_CSS_REGEX = /-[0-9a-f]{8}\.css$/

Instance methods

bun_asset(path : String) : String

Returns the public path for a manifest asset.

bun_css_tag(source : String, **options) : String

Generates a <link> tag for a CSS entry point.

In development, non-fingerprinted CSS links are cache-busted with a timestamp query parameter.

bun_img_tag(source : String, alt : String | Nil = nil, **options) : String

Generates an <img> tag for an image asset.

Subresource Integrity is intentionally not rendered on images: browsers do not enforce SRI for <img> elements.

bun_js_tag(source : String, **options) : String

Generates a <script> tag for a JS entry point.