Web::AssetLib::Asset - a representation of a particular asset in your library
my $asset = Web::AssetLib::Asset->new( type => 'javascript', input_engine => 'LocalFile', rank => -100, input_args => { path => "your/local/path/jquery.min.js", } );
File type string. Currently supports: js, javascript, css, stylesheet, jpeg, jpg
string; partial class name that will match one of the provided input_engines for your library (defaults to "LocalFile")
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)
hashref; a place to store arguments that the various input plugins may require for a given asset (see input plugin docs for specific requirements)
boolean; assets marked isPassthru will not be minified or concatenated
hashref; provides html attribute defaults for as_html()
as_html()
$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.)
$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.)
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.
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.
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.
Ryan Lang <rlang@cpan.org>
To install Web::AssetLib, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Web::AssetLib
CPAN shell
perl -MCPAN -e shell install Web::AssetLib
For more information on module installation, please visit the detailed CPAN module installation guide.