Mason:...:Defer(3pm)

πŸ“¦
version 2.24 Β· 2 versions
  • 2.24 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 2.24 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Mason::Plugin::Defer ✨

ok so bestie, welcome to Mason::Plugin::Defer β€” it's part of the Mason plugin fam, and it ships in the User Contributed Perl Documentation collection as the 3pm page. This one is lowkey iconic: it lets you defer computing parts of output until the end of the request. πŸ¦‹


πŸŽ€ NAME πŸŽ€

Mason::Plugin::Defer β€” defer computing parts of output until the end of the request πŸ’…


🌸 SYNOPSIS 🌸

<head>
<title><% $m->defer(sub { $m->page->title }) %></title>

% $.Defer {{
%   my $content = join(", ", @{ $m->page->meta_content });
<meta name="description" content="<% $content %>">
% }}

<body>
...

✨ DESCRIPTION ✨

So the defer feature lets chunks of your output just… chill until the end of the request. 🌈 No cap.

You can set up multiple deferred code blocks, and every single one of them will execute and insert itself into the output stream at request end. It's giving "we'll get to it, bestie" and honestly? slay. πŸ‘‘


πŸ’– REQUEST METHOD πŸ’–

defer (code)

Returns a marker string that is unique and will not appear in normal output. 🫢 At the end of the request, each marker string is replaced with the output of its associated code. fr fr.

e.g.

<title><% $m->defer(sub { $m->page->title }) %></title>

πŸ¦‹ FILTER πŸ¦‹

Defer

Applies $m->defer to the content block. e.g.

% $.Defer {{
%   my $content = join(", ", @{ $m->page->meta_content });
<meta name="description" content="<% $content %>">
% }}

πŸ‘€ SEE ALSO πŸ‘€

  • Mason

🌟 AUTHOR 🌟

Jonathan Swartz <swartz@pobox.com>


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 that's the whole page, no notes πŸ’–

perl v5.34.0 Β· 2022-05-27 Β· and that's a wrap on the Mason:...:Defer(3pm) page, mwah πŸ’…πŸŽ€βœ¨

πŸ“¦ where this page comes from