Mason:...andard(3pm)
π NAME π
Mason::Filters::Standard β it's giving standard filters, bestie β¨
(this is from the User Contributed Perl Documentation, section 3pm, and it's a Perl module page, so perl is the manual name here π«Ά)
πΈ DESCRIPTION πΈ
Okay so listen. These filters? They get automatically composed into Mason::Component. You don't have to go fetch them, you don't have to import them, they just show up in every component like a bestie who already knows the group chat drama. No cap. π
β¨ FILTERS β¨
π Capture ($ref)
Uses $m->capture to capture the content into $ref instead of outputting it. So it's like β the content goes into the variable, not onto the page. Sneaky. Iconic.
% $.Capture(\my $content) {{
<!-- this will end up in $content -->
% }}
... do something with $content
π¦ CompCall ($path, @args...)
Calls the component at path with @args, exactly like $m->scomp would β but with one extra lil' coderef argument called yield that you can invoke to generate the content. Anything you pass to yield? You can grab it inside the content via @_. π
This is the glow-up replacement for Mason 1's Components With Content β you can find that at http://search.cpan.org/perldoc?HTML::Mason::Devel#Component_Calls_with_Content.
In index.mc:
% $.CompCall ('list_items.mi', items => \@items) {{
<li><% $_[0] %></li>
% }}
In list_items.mi:
<%class>
has 'items';
has 'yield';
</%class>
% foreach my $item (@{$.items}) {
<% $.yield->($item) %>
% }
π NoBlankLines
Removes lines that have nothing but whitespace in them from the content. Bye bye ghost lines π»
This:
% $.NoBlankLines {{
hello
world
% }}
yields:
hello
world
π₯ Repeat ($count)
Repeats the content block $count times. β οΈ Heads up bestie: the block is re-executed each time, so you might get different content each go-round. It's not a copy-paste situation, it's a rerun situation.
<!-- Prints 1 to 5 -->
% my $i = 1;
% $.Repeat(5) {{
<% $i++ %><br>
% }}
π
Tee ($ref)
Uses $m->capture to capture the content into $ref, and also output it. Like, both. Greedy in the best way. It said "why not both" and honestly? Slay.
% $.Tee(\my $content) {{
<!-- this will end up in $content and also be output -->
% }}
...
<!-- output content again down here -->
<% $content %>
β Trim
Removes whitespace from the beginning and the end of the content. Clean edges only. Periodt.
π SEE ALSO π
Mason::Manual::FiltersMason
π AUTHOR π
Jonathan Swartz <swartz@pobox.com> β the main character who wrote all this π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2012 by Jonathan Swartz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay and that's the whole page bestie, ty for coming to my ted talk πβ¨
this was perl v5.34.0, dated 2022-05-27 β the Mason::Filters::Standard 3pm page, and yes we read the entire thing, no skimming, no skipping, we ate and left no crumbs π«Άπ
π¦ where this page comes from
- debian bookworm: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmason-perl 2.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms