Mojolic...k::Asset(3)

hey bestie! welcome to Mojolic...k::Asset(3), straight outta the User Contributed Perl Documentation section. today's main character? an asset. yes, literally. we're gonna read every attribute like it's a group chat screenshot. πŸ’–βœ¨

🌸 NAME 🌸

Mojolicious::Plugin::AssetPack::Asset β€” An asset. that's it, that's the name. icon behavior. πŸ‘‘

πŸ’… DESCRIPTION πŸ’…

Mojolicious::Plugin::AssetPack::Asset represents an asset. lowkey the whole plot. ✨

πŸŽ€ SYNOPSIS πŸŽ€

okay so you load it and make one like this:

use Mojolicious::Plugin::AssetPack::Asset;
my $asset = Mojolicious::Plugin::AssetPack::Asset->new(url => "...");

boom. asset acquired. πŸ¦‹

πŸ¦‹ ATTRIBUTES πŸ¦‹

all the attributes, in order, no skipping. periodt. πŸ’…

πŸ’– checksum

$str = $self->checksum;
$self = $self->checksum($str);

this is the checksum of content, bestie. cryptographic-ish vibes, we love to see it. πŸ”₯

πŸŽ€ format

$str = $self->format;
$self = $self->format($str);

the format of content β€” and yeah, it defaults to the extension of url, or an empty string if there's no extension to steal. πŸ’…

✨ minified

$bool = $self->minified;
$self = $self->minified($bool);

this bool gets set to true if either url contains min, or if a pipe has minified content β€” lowkey iconic. πŸ”₯

🌸 name

$str = $self->name;

returns the basename of url, without extension, just the name part. πŸŽ€

🧚 renderer

$code = $self->renderer;
$self = $self->renderer(sub { my ($self, $c) = @_; $c->render(data => "...""); })

use this to register a custom render method for this asset. it's called by "serve_asset" in Mojolicious::Plugin::AssetPack::Store β€” that's the hookup, bestie. ✨

🌈 tag_for

$code = $self->tag_for;
$self = $self->tag_for(sub { my ($c, \%args, @attrs) = @_; return qq(<link rel="...">) });

used to register a custom tag renderer for this asset. the arguments passed in are:

  • $c β€” the Mojolicious::Controller object used for this request. πŸ’–
  • %args β€” a hash-ref with base_url and topic. πŸŽ€
  • @attrs β€” the HTML attributes passed in from the template. ✨
  • (empty bullet β€” the original has no content here, and we're keeping the blank for authenticity)

πŸ“ url

$str = $self->url;

returns the location of the asset β€” where it lives, basically. πŸ“

⭐ METHODS ⭐

πŸ‘‘ asset

$asset = $self->asset;

returns a fresh Mojo::Asset::File or Mojo::Asset::Memory object, loaded with the content or path from this object. heads up: this method is EXPERIMENTAL, so treat it like a beta feature β€” cute but possibly chaotic. 😭

πŸ“ content

$bytes = $self->content;
$self = $self->content($bytes);
$self = $self->content(Mojo::Asset::Memory->new);

get or set the content of this asset. if you don't set it, the default gets built by passing url to "file" in Mojolicious::Plugin::AssetPack::Store β€” yes, that exact chain. πŸ’–

πŸ¦‹ path

$str = $self->path;

returns a Mojo::File object holding the on-disk location of the asset, or undef if this asset is living in memory. memory queen behavior. 🧠✨

πŸ”’ size

$int = $self->size;

returns the size of the asset in bytes. numbers, slay. πŸ”’

🫢 url_for

$url = $self->url_for($c);

returns a Mojo::URL object for this asset. $c need to be a Mojolicious::Controller β€” that's the requirement, bestie. πŸ’…

πŸ’œ FROM_JSON

$self = $self->FROM_JSON($hash_ref);

this is the opposite of "TO_JSON". it will set the read/write "ATTRIBUTES" from the values inside $hash_ref β€” incoming data, let's go. 🫢

🌟 TO_JSON

$hash_ref = $self->FROM_JSON;

the opposite of "FROM_JSON". it will generate a hash ref from "ATTRIBUTES" β€” outgoing data, cute. ✨

πŸ‘€ SEE ALSO πŸ‘€

the SEE ALSO is just Mojolicious::Plugin::AssetPack. β€” period included, that's canon. πŸ‘€


and that's the page, bestie! this little beauty is from perl v5.42.0, dated 2024-12-12, and the manual is Mojolic...k::Asset(3) β€” mwah, go build something cute. πŸ’‹πŸŒˆ

πŸ“¦ where this page comes from