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β theMojolicious::Controllerobject used for this request. π%argsβ a hash-ref withbase_urland 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
- opensuse-leap 16.0: perl-Mojolicious-Plugin-AssetPack 2.150.0-bp160.1.11 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms