module Amber::Controller::Helpers::AssetHelpers

Direct including types

Defined in:

amber/controller/helpers/asset_helpers.cr

Instance Method Summary

Instance Method Detail

def asset_integrity(path : String) : String #

Returns the Subresource Integrity value recorded for a logical asset.


[View source]
def asset_path(path : String) : String #

Resolves a logical, build-authored asset name through the persisted manifest. Already-public URLs remain unchanged for backwards compatibility.


[View source]
def favicon_tag(path : String = "/favicon.ico") : String #

Generates a favicon link tag.

favicon_tag                     # => "<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />"
favicon_tag("/images/icon.png") # => "<link rel=\"icon\" type=\"image/x-icon\" href=\"/images/icon.png\" />"

[View source]
def image_tag(src : String, **attrs) : String #

Generates an image tag.

image_tag("images/logo.png") # resolves through the asset manifest
image_tag("images/logo.png", alt: "Logo")
image_tag("images/photo.jpg", width: "200", height: "100")

[View source]
def javascript_importmap_tag(imports : Hash(String, String), preload : Array(String) = [] of String) : String #

Generates a safe inline import map and optional local module preloads. Local values are resolved through the same asset manifest as other tags.


[View source]
def javascript_include_tag(path : String, **attrs) : String #

Generates a script tag for including JavaScript.

javascript_include_tag("javascript/app.js")
# Resolves the fingerprinted URL and adds its integrity value.

[View source]
def stylesheet_link_tag(path : String, **attrs) : String #

Generates a stylesheet link tag.

stylesheet_link_tag("stylesheets/app.css")
# Resolves the fingerprinted URL and adds its integrity value.

[View source]