1Mojolicious::Plugin::AsUsseetrPaCcokn:t:rAisbsuette(d3M)PoejrolliDcoicouumse:n:tPaltuigoinn::AssetPack::Asset(3)
2
3
4

NAME

6       Mojolicious::Plugin::AssetPack::Asset - An asset
7

DESCRIPTION

9       Mojolicious::Plugin::AssetPack::Asset represents an asset.
10

SYNOPSIS

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

ATTRIBUTES

16   checksum
17         $str = $self->checksum;
18         $self = $self->checksum($str);
19
20       The checksum of "content".
21
22   format
23         $str = $self->format;
24         $self = $self->format($str);
25
26       The format of "content". Defaults to the extension of "url" or empty
27       string.
28
29   minified
30         $bool = $self->minified;
31         $self = $self->minified($bool);
32
33       Will be set to true if either "url" contains "min" or if a pipe has
34       minified "content".
35
36   name
37         $str = $self->name;
38
39       Returns the basename of "url", without extension.
40
41   renderer
42         $code = $self->renderer;
43         $self = $self->renderer(sub { my ($self, $c) = @_; $c->render(data => "...""); })
44
45       Can be used to register a custom render method for this asset. This is
46       called by "serve_asset" in Mojolicious::Plugin::AssetPack::Store.
47
48   tag_for
49         $code = $self->tag_for;
50         $self = $self->tag_for(sub { my ($c, \%args, @attrs) = @_; return qq(<link rel="...">) });
51
52       Used to register a custom tag renderer for this asset. The arguments
53       passed in are:
54
55       · $c
56
57         The Mojolicious::Controller object used for this request.
58
59       · %args
60
61         A hash-ref with "base_url" and topic.
62
63       · @attrs
64
65         The HTML attributes passed in from the template.
66
67       ·
68
69
70   url
71         $str = $self->url;
72
73       Returns the location of the asset.
74

METHODS

76   asset
77         $asset = $self->asset;
78
79       Returns a new Mojo::Asset::File or Mojo::Asset::Memory object, with the
80       content or path from this object.
81
82       This method is EXPERIMENTAL.
83
84   content
85         $bytes = $self->content;
86         $self = $self->content($bytes);
87         $self = $self->content(Mojo::Asset::Memory->new);
88
89       Used to get or set the content of this asset. The default will be built
90       from passing "url" to "file" in Mojolicious::Plugin::AssetPack::Store.
91
92   path
93         $str = $self->path;
94
95       Returns a Mojo::File object that holds the location to the asset on
96       disk or "undef" if this asset is in memory.
97
98   size
99         $int = $self->size;
100
101       Returns the size of the asset in bytes.
102
103   url_for
104         $url = $self->url_for($c);
105
106       Returns a Mojo::URL object for this asset. $c need to be a
107       Mojolicious::Controller.
108
109   FROM_JSON
110         $self = $self->FROM_JSON($hash_ref);
111
112       The opposite of "TO_JSON". Will set the read/write "ATTRIBUTES" from
113       the values in $hash_ref.
114
115   TO_JSON
116         $hash_ref = $self->FROM_JSON;
117
118       The opposite of "FROM_JSON". Will generate a hash ref from
119       "ATTRIBUTES".
120

SEE ALSO

122       Mojolicious::Plugin::AssetPack.
123
124
125
126perl v5.32.0                      2020-M1o0j-o0l4icious::Plugin::AssetPack::Asset(3)
Impressum