| 1 | package Catalyst::Controller::AutoAssets::Handler::JS; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | # VERSION | ||
| 6 | |||
| 7 | use Moose; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | extends 'Catalyst::Controller::AutoAssets::Handler::CSS'; | ||
| 11 | |||
| 12 | use Module::Runtime; | ||
| 13 | |||
| 14 | has 'minifier', is => 'ro', isa => 'Maybe[CodeRef]', lazy => 1, default => sub { | ||
| 15 | my $self = shift; | ||
| 16 | Module::Runtime::require_module('JavaScript::Minifier'); | ||
| 17 | return sub { JavaScript::Minifier::minify(@_) }; | ||
| 18 | }; | ||
| 19 | |||
| 20 | has 'asset_content_type', is => 'ro', isa => 'Str', default => 'text/javascript'; | ||
| 21 | has 'ext', is => 'ro', isa => 'Str', default => 'js'; | ||
| 22 | |||
| 23 | sub html_head_tags { | ||
| 24 | my $self = shift; | ||
| 25 | return | ||
| 26 | "<!-- AUTO GENERATED BY " . ref($self->Controller) . " (/" . | ||
| 27 | $self->action_namespace($self->_app) . ") -->\r\n" . | ||
| 28 | '<script type="text/javascript" src="' . | ||
| 29 | $self->asset_path . | ||
| 30 | '"></script>' . | ||
| 31 | "\r\n<!-- ---- END AUTO GENERATED ASSETS ---- -->\r\n"; | ||
| 32 | } | ||
| 33 | |||
| 34 | 1; | ||
| 35 | |||
| 36 | __END__ | ||
| 37 | |||
| 38 | =pod | ||
| 39 | |||
| 40 | =head1 NAME | ||
| 41 | |||
| 42 | Catalyst::Controller::AutoAssets::Handler::JS - JS type handler | ||
| 43 | |||
| 44 | =head1 DESCRIPTION | ||
| 45 | |||
| 46 | This is the Handler class for the 'JS' asset type. This is a core type and is | ||
| 47 | documented in L<Catalyst::Controller::AutoAssets>. | ||
| 48 | |||
| 49 | =head1 SEE ALSO | ||
| 50 | |||
| 51 | =over | ||
| 52 | |||
| 53 | =item L<Catalyst::Controller::AutoAssets::Handler> | ||
| 54 | |||
| 55 | =back | ||
| 56 | |||
| 57 | =head1 AUTHOR | ||
| 58 | |||
| 59 | Henry Van Styn <vanstyn@cpan.org> | ||
| 60 | |||
| 61 | =head1 COPYRIGHT AND LICENSE | ||
| 62 | |||
| 63 | This software is copyright (c) 2013 by IntelliTree Solutions llc. | ||
| 64 | |||
| 65 | This is free software; you can redistribute it and/or modify it under | ||
| 66 | the same terms as the Perl 5 programming language system itself. | ||
| 67 | |||
| 68 | =cut |