Mojolicious::Plugin::AssetPack::Asset(3pm) | User Contributed Perl Documentation | Mojolicious::Plugin::AssetPack::Asset(3pm) |
Mojolicious::Plugin::AssetPack::Asset - An asset
Mojolicious::Plugin::AssetPack::Asset represents an asset.
use Mojolicious::Plugin::AssetPack::Asset; my $asset = Mojolicious::Plugin::AssetPack::Asset->new(url => "...");
$str = $self->checksum; $self = $self->checksum($str);
The checksum of "content".
$str = $self->format; $self = $self->format($str);
The format of "content". Defaults to the extension of "url" or empty string.
$bool = $self->minified; $self = $self->minified($bool);
Will be set to true if either "url" contains "min" or if a pipe has minified "content".
$str = $self->name;
Returns the basename of "url", without extension.
$code = $self->renderer; $self = $self->renderer(sub { my ($self, $c) = @_; $c->render(data => "...""); })
Can be used to register a custom render method for this asset. This is called by "serve_asset" in Mojolicious::Plugin::AssetPack::Store.
$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:
The Mojolicious::Controller object used for this request.
A hash-ref with "base_url" and topic.
The HTML attributes passed in from the template.
$str = $self->url;
Returns the location of the asset.
$asset = $self->asset;
Returns a new Mojo::Asset::File or Mojo::Asset::Memory object, with the content or path from this object.
This method is EXPERIMENTAL.
$bytes = $self->content; $self = $self->content($bytes); $self = $self->content(Mojo::Asset::Memory->new);
Used to get or set the content of this asset. The default will be built from passing "url" to "file" in Mojolicious::Plugin::AssetPack::Store.
$str = $self->path;
Returns a Mojo::File object that holds the location to the asset on disk or "undef" if this asset is in memory.
$int = $self->size;
Returns the size of the asset in bytes.
$url = $self->url_for($c);
Returns a Mojo::URL object for this asset. $c need to be a Mojolicious::Controller.
$self = $self->FROM_JSON($hash_ref);
The opposite of "TO_JSON". Will set the read/write "ATTRIBUTES" from the values in $hash_ref.
$hash_ref = $self->FROM_JSON;
The opposite of "FROM_JSON". Will generate a hash ref from "ATTRIBUTES".
Mojolicious::Plugin::AssetPack.
2023-02-04 | perl v5.36.0 |