File Coverage

blib/lib/Mason/Plugin/Defer.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package Mason::Plugin::Defer;
2             $Mason::Plugin::Defer::VERSION = '2.23';
3 20     20   10926 use Moose;
  20         33  
  20         138  
4             with 'Mason::Plugin';
5              
6             __PACKAGE__->meta->make_immutable();
7              
8             1;
9              
10             __END__
11              
12             =pod
13              
14             =head1 NAME
15              
16             Mason::Plugin::Defer - Defer computing parts of output until the end of the
17             request
18              
19             =head1 SYNOPSIS
20              
21             <head>
22             <title><% $m->defer(sub { $m->page->title }) %></title>
23              
24             % $.Defer {{
25             % my $content = join(", ", @{ $m->page->meta_content });
26             <meta name="description" content="<% $content %>">
27             % }}
28              
29             <body>
30             ...
31              
32             =head1 DESCRIPTION
33              
34             The I<defer> feature allows sections of output to be deferred til the end of
35             the request. You can set up multiple deferred code blocks which will execute
36             and insert themselves into the output stream at request end.
37              
38             =head1 REQUEST METHOD
39              
40             =over
41              
42             =item defer (code)
43              
44             Returns a marker string that is unique and will not appear in normal output. At
45             the end of the request, each marker string is replaced with the output of its
46             associated code. e.g.
47              
48             <title><% $m->defer(sub { $m->page->title }) %></title>
49              
50             =back
51              
52             =head1 FILTER
53              
54             =over
55              
56             =item Defer
57              
58             Applies C<< $m->defer >> to the content block. e.g.
59              
60             % $.Defer {{
61             % my $content = join(", ", @{ $m->page->meta_content });
62             <meta name="description" content="<% $content %>">
63             % }}
64              
65             =back
66              
67             =head1 SEE ALSO
68              
69             L<Mason|Mason>
70              
71             =head1 AUTHOR
72              
73             Jonathan Swartz <swartz@pobox.com>
74              
75             =head1 COPYRIGHT AND LICENSE
76              
77             This software is copyright (c) 2012 by Jonathan Swartz.
78              
79             This is free software; you can redistribute it and/or modify it under
80             the same terms as the Perl 5 programming language system itself.
81              
82             =cut