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. See "ASSETS FROM CUSTOM DOMAIN"
62         in Mojolicious::Plugin::AssetPack::Guides::Cookbook of example
63         "base_url".
64
65       · @attrs
66
67         The HTML attributes passed in from the template.
68
69       ·
70
71
72   url
73         $str = $self->url;
74
75       Returns the location of the asset.
76

METHODS

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

SEE ALSO

124       Mojolicious::Plugin::AssetPack.
125
126
127
128perl v5.30.1                      2020-M0o1j-o3l0icious::Plugin::AssetPack::Asset(3)
Impressum