NAME
Web::AssetLib::Asset - a representation of a particular asset in your library
SYNOPSIS
my $asset = Web::AssetLib::Asset->new(
type => 'javascript',
input_engine => 'LocalFile',
rank => -100,
input_args => { path => "your/local/path/jquery.min.js", }
);
ATTRIBUTES
type (required)
File type string. Currently supports: js, javascript, css, stylesheet, jpeg, jpg
input_engine
string; partial class name that will match one of the provided input_engines for your library (defaults to "LocalFile")
rank
number; Assets added to bundles will be exported in the order in which they are added. If an asset should be exported in a different order, provide a rank. Lower numbers will result in the asset being compiled earlier, and higher numbers will result in the asset being compiled later. (defaults to 0)
input_args
hashref; a place to store arguments that the various input plugins may require for a given asset (see input plugin docs for specific requirements)
isPassthru
boolean; assets marked isPassthru will not be minified or concatenated
default_html_attrs
hashref; provides html attribute defaults for as_html()
METHODS
set_digest
$asset->set_digest( $digest );
Stores the digest in the Asset object. (It is required that this value be set, if writing your own input engine.)
set_contents
$asset->set_contents( $contents );
Stores the file contents in the Asset object. (It is required that this value be set, if writing your own input engine.)
fingerprint
my $fingerprint = $asset->fingerprint();
(Somewhat) unique identifier for asset, created by concatenating and hashing: type, input_engine, and input_args. Helpful to identify asset uniqueness prior to opening and reading the file.
digest
my $digest = $asset->digest();
Truly unique identifier for asset - an MD5 file digest. Only available after the file has been opened and read (compile() has been called on asset), otherwise returns undef.
as_html
my $html_tag = $asset->as_html( html_attrs => { async => 'async' } );
Returns an HTML-formatted string linking to asset's output location. Only available after the file has been opened and read (compile() has been called on asset), otherwise returns undef.
AUTHOR
Ryan Lang <rlang@cpan.org>