.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mojolicious::Plugin::AssetPack::Pipe 3pm" .TH Mojolicious::Plugin::AssetPack::Pipe 3pm "2023-02-04" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mojolicious::Plugin::AssetPack::Pipe \- Base class for a pipe .SH "SYNOPSIS" .IX Header "SYNOPSIS" .SS "Write a custom pipe" .IX Subsection "Write a custom pipe" .Vb 3 \& package MyApp::MyCoolPipe; \& use Mojo::Base "Mojolicious::Plugin::AssetPack::Pipe"; \& use Mojolicious::Plugin::AssetPack::Util qw(diag DEBUG); \& \& sub process { \& my ($self, $assets) = @_; \& \& # Normally a Mojolicious::Plugin::AssetPack::Store object \& my $store = $self\->assetpack\->store; \& \& # Loop over Mojolicious::Plugin::AssetPack::Asset objects \& $assets\->each( \& sub { \& my ($asset, $index) = @_; \& \& # Skip every file that is not css \& return if $asset\->format ne "css"; \& \& # Change $attr if this pipe will modify $asset attributes \& my $attr = $asset\->TO_JSON; \& my $content = $asset\->content; \& \& # Private name to load/save meta data under \& $attr\->{key} = "coolpipe"; \& \& # Return asset if already processed \& if ($content !~ /white/ and $file = $store\->load($attr)) { \& return $asset\->content($file); \& } \& \& # Process asset content \& diag q(Replace white with red in "%s".), $asset\->url if DEBUG; \& $content =~ s!white!red!g; \& $asset\->content($store\->save(\e$content, $attr))\->minified(1); \& } \& ); \& } .Ve .SS "Use the custom pipe" .IX Subsection "Use the custom pipe" .Vb 2 \& use Mojolicious::Lite; \& plugin AssetPack => {pipes => [qw(MyApp::MyCoolPipe Css)]}; .Ve .PP Note that the above will not load the other default pipes, such as Mojolicious::Plugin::AssetPack::Pipe::JavaScript. .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is the base class for all pipe classes. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .SS "assetpack" .IX Subsection "assetpack" .Vb 1 \& $obj = $self\->assetpack; .Ve .PP Holds a Mojolicious::Plugin::AssetPack object. .SS "topic" .IX Subsection "topic" .Vb 2 \& $str = $self\->topic; \& $self = $self\->topic("app.css"); .Ve .PP Returns the name of the current asset topic. .SH "METHODS" .IX Header "METHODS" .SS "after_process" .IX Subsection "after_process" .Vb 1 \& $self\->after_process(Mojo::Collection\->new); .Ve .PP \&\*(L"process\*(R" in Mojolicious::Plugin::AssetPack will call this method before any of the pipe \*(L"process\*(R" method is called. .PP Note that this method is not defined in Mojolicious::Plugin::AssetPack::Pipe! .SS "app" .IX Subsection "app" .Vb 1 \& $obh = $self\->app; .Ve .PP Returns the Mojolicious application object. .SS "before_process" .IX Subsection "before_process" .Vb 1 \& $self\->before_process(Mojo::Collection\->new); .Ve .PP \&\*(L"process\*(R" in Mojolicious::Plugin::AssetPack will call this method after all of the pipes \*(L"process\*(R" method is called. .PP Note that this method is not defined in Mojolicious::Plugin::AssetPack::Pipe! .SS "process" .IX Subsection "process" .Vb 1 \& $self\->process(Mojo::Collection\->new); .Ve .PP A method used to process the assets. Each of the element in the collection will be a Mojolicious::Plugin::AssetPack::Asset object or an object with the same \&\s-1API.\s0 .PP This method need to be defined in the subclass. .SS "run" .IX Subsection "run" .Vb 1 \& $self\->run([som_app => @args], \e$stdin, \e$stdout, ...); .Ve .PP See \*(L"run3\*(R" in IPC::Run3 for details about the arguments. This method will try to call \f(CW\*(C`_install_some_app()\*(C'\fR unless \*(L"som_app\*(R" was found in \&\s-1PATH\s0. This method could then try to install the application and must return the path to the installed application. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "\(bu" 2 Mojolicious::Plugin::AssetPack .IP "\(bu" 2 Mojolicious::Plugin::AssetPack::Asset .IP "\(bu" 2 Mojolicious::Plugin::AssetPack::Store .IP "\(bu" 2 Mojolicious::Plugin::AssetPack::Util