table of contents
Mojolicious::Plugin::AssetPack::Asset(3pm) | User Contributed Perl Documentation | Mojolicious::Plugin::AssetPack::Asset(3pm) |
NAME¶
Mojolicious::Plugin::AssetPack::Asset - An asset
DESCRIPTION¶
Mojolicious::Plugin::AssetPack::Asset represents an asset.
SYNOPSIS¶
use Mojolicious::Plugin::AssetPack::Asset; my $asset = Mojolicious::Plugin::AssetPack::Asset->new(url => "...");
ATTRIBUTES¶
checksum¶
$str = $self->checksum; $self = $self->checksum($str);
The checksum of "content".
format¶
$str = $self->format; $self = $self->format($str);
The format of "content". Defaults to the extension of "url" or empty string.
minified¶
$bool = $self->minified; $self = $self->minified($bool);
Will be set to true if either "url" contains "min" or if a pipe has minified "content".
name¶
$str = $self->name;
Returns the basename of "url", without extension.
renderer¶
$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.
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.
url¶
$str = $self->url;
Returns the location of the asset.
METHODS¶
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.
content¶
$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.
path¶
$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.
size¶
$int = $self->size;
Returns the size of the asset in bytes.
url_for¶
$url = $self->url_for($c);
Returns a Mojo::URL object for this asset. $c need to be a Mojolicious::Controller.
FROM_JSON¶
$self = $self->FROM_JSON($hash_ref);
The opposite of "TO_JSON". Will set the read/write "ATTRIBUTES" from the values in $hash_ref.
TO_JSON¶
$hash_ref = $self->FROM_JSON;
The opposite of "FROM_JSON". Will generate a hash ref from "ATTRIBUTES".
SEE ALSO¶
Mojolicious::Plugin::AssetPack.
2024-12-07 | perl v5.40.0 |