Text::...Process(3pm)

πŸ“¦
version 2.23 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Text::...Process(3pm) ✨

okay bestie, so this is the manual page for Text::MicroMason::PostProcess β€” the mixin that slaps filters on ALL your template output πŸ’… it's giving "glow-up for your strings" and honestly? iconic.


🌸 NAME 🌸

Text::MicroMason::PostProcess β€” Apply Filters to All Template Output

like. it post-processes. it filters. it's the vibe check your output goes through before anyone sees it πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

bestie do NOT use this class directly, okay? the whole point is you pass its name so it gets mixed in:

use Text::MicroMason;
my $mason = Text::MicroMason->new( -PostProcess );

then you use the standard compile and execute methods to parse and evaluate templates like always:

print $mason->compile( text=>$template )->( @%args );
print $mason->execute( text=>$template, @args );

you can also define output filters when you create the thing, or later on, no biggie:

$mason = Text::MicroMason->new( -PostProcess, post_process => $func );

$mason->post_processors( $func );

$mason->compile( text => $template, post_process => $func );

$mason->execute( text => $template, { post_process => $func }, @args );

see? flexible. main character energy. ✨


πŸ’– DESCRIPTION πŸ’–

This mixin class adds filtering of all template output to any MicroMason class. yes, ALL of it. every last string. obsessed.

Filter functions can accept the string to be output and return a filtered version:

$mason->post_process( sub {
  my $foo = shift;
  $foo =~ s/a-Z/A-Z/;
  return $foo;
} );

and lowkey here's the cute part β€” if a filter function has an empty prototype, it's assumed to work on $_:

$mason->post_process( sub () {
  s/a-Z/A-Z/
} );

so tiny. so powerful. 🫢


🌈 Public Methods 🌈

  • post_processors() β€” Gets and sets the functions to be used for output filtering.

Called with no arguments, returns the list of filter functions:

my @functions = $mason->post_processors();

Called with one array-ref argument, sets the list of filter functions:

$mason->post_processors( \@functions );

Called with one or more function-ref arguments, appends to the list:

$mason->post_processors( $filter1, $filter2 );

getter, setter, appender β€” she does it all fr fr πŸ‘‘


πŸ¦‹ Supported Attributes πŸ¦‹

  • post_process β€” Stores a reference to a function or an array of functions to be used:
$mason->{post_process} = $function;
$mason->{post_process} = [ $function1, $function2 ];

You can set this attribute when you create your mason object, or in calls to the compile and execute methods. whenever you want, bestie πŸ’œ


🧚 Private Methods 🧚

  • post_process()
$mason->post_process( $output ) : $filtered_output

Applies the post-processing filter. that's the whole job. she's focused. she's efficient. periodt. πŸ’…


⭐ SEE ALSO ⭐

  • For an overview of this templating framework, see Text::MicroMason.
  • This is a mixin class intended for use with Text::MicroMason::Base.
  • For distribution, installation, support, copyright and license information, see Text::MicroMason::Docs::ReadMe.

no cap, if you're looking for the boring version of this page, it's not here β€” but every single fact is, so you're welcome πŸ“

that's a wrap, bestie!! this page was brought to you by perl v5.36.0 and dated 2023-08-10 β€” go forth and filter your output, you absolute legend πŸŒˆβœ¨πŸ’–

πŸ“¦ where this page comes from