fix packing in templates and snippets
This commit is contained in:
parent
cd8456ee99
commit
bd80af6b60
2 changed files with 33 additions and 26 deletions
|
|
@ -35,38 +35,44 @@ property snippet => (
|
||||||
hoverHelp => ['snippet description','Asset_Snippet'],
|
hoverHelp => ['snippet description','Asset_Snippet'],
|
||||||
default => undef,
|
default => undef,
|
||||||
);
|
);
|
||||||
around snippet => sub {
|
sub _trigger_snippet {
|
||||||
my $orig = shift;
|
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
if (@_ > 1) {
|
my ($new, $old) = @_;
|
||||||
my $packed = $_[0];
|
if ($new ne $old) {
|
||||||
if ( $self->mimeType eq "text/html" ) {
|
$self->_clear_snippetPacked;
|
||||||
HTML::Packer::minify( \$packed, {
|
|
||||||
remove_comments => 1,
|
|
||||||
do_javascript => "shrink",
|
|
||||||
do_stylesheet => "minify",
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
elsif ( $self->mimeType eq "text/css" ) {
|
|
||||||
CSS::Packer::minify( \$packed, {
|
|
||||||
compress => 'minify',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
elsif ( $self->mimeType eq 'text/javascript' ) {
|
|
||||||
JavaScript::Packer::minify( \$packed, {
|
|
||||||
compress => "shrink",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$self->snippetPacked($packed);
|
|
||||||
}
|
}
|
||||||
$self->$orig(@_);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
property snippetPacked => (
|
property snippetPacked => (
|
||||||
fieldType => "hidden",
|
fieldType => "hidden",
|
||||||
default => undef,
|
|
||||||
noFormPost => 1,
|
noFormPost => 1,
|
||||||
|
lazy => 1,
|
||||||
|
clearer => '_clear_snippetPacked',
|
||||||
|
builder => '_build_snippetPacked',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
sub _build_snippetPacked {
|
||||||
|
my $self = shift;
|
||||||
|
my $snippet = $self->snippet;
|
||||||
|
if ( $self->mimeType eq "text/html" ) {
|
||||||
|
HTML::Packer::minify( \$snippet, {
|
||||||
|
remove_comments => 1,
|
||||||
|
do_javascript => "shrink",
|
||||||
|
do_stylesheet => "minify",
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
elsif ( $self->mimeType eq "text/css" ) {
|
||||||
|
CSS::Packer::minify( \$snippet, {
|
||||||
|
compress => 'minify',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
elsif ( $self->mimeType eq 'text/javascript' ) {
|
||||||
|
JavaScript::Packer::minify( \$snippet, {
|
||||||
|
compress => "shrink",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$snippet;
|
||||||
|
}
|
||||||
|
|
||||||
property usePacked => (
|
property usePacked => (
|
||||||
tab => 'properties',
|
tab => 'properties',
|
||||||
fieldType => 'yesNo',
|
fieldType => 'yesNo',
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ sub _build_templatePacked {
|
||||||
do_javascript => 'shrink',
|
do_javascript => 'shrink',
|
||||||
do_stylesheet => 'minify',
|
do_stylesheet => 'minify',
|
||||||
} );
|
} );
|
||||||
|
$template;
|
||||||
}
|
}
|
||||||
|
|
||||||
property usePacked => (
|
property usePacked => (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue