lib/MojoMojo/Formatter/Comment.pm

filter: Statementstmt 100% 13 / 13 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 3 / 3 totaltotal 100% 22 / 22 CC 2 SCAR 3.4
CC
2
Cov
100%
format_content
2.0
BEGIN
1.0
format_content_order
1.0
CRAP 1.4
« lib/MojoMojo/Schema/Result/Tag.pm ↑ Summary lib/MojoMojo/Formatter/File/Pod.pm »
1 package MojoMojo::Formatter::Comment;
2  
3 26 ▶use parent qw/MojoMojo::Formatter/;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 NAME
6  
7 MojoMojo::Formatter::Comment - Include comments on your page.
8  
9 =head1 DESCRIPTION
10  
11 This is a hook for the page comment functionality. It allows a
12 comment box to be placed anywhere on your page through the {{comments}}
13 tag.
14  
15 =head1 METHODS
16  
17 =head2 format_content_order
18  
19 Format order can be 1-99. The Comment formatter runs on 91.
20  
21 =cut
22  
23 868 ▶sub format_content_order { 91 }
Subroutine format_content_order: called CC=1 SCAR=0.0
Pod documented
24  
25 =head2 format_content
26  
27 Calls the formatter. Takes a ref to the content as well as the
28 context object.
29  
30 =cut
31  
32 124 ▶sub format_content {
Subroutine format_content: called CC=2 SCAR=6.9
Pod documented
33 124 my ( $class, $content, $c, $self ) = @_;
34 124 my $re=$class->gen_re('comments');
35 124 ▶ if ( $$content =~ s|$re|show_comments($c,$c->stash->{page})|xme ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$content =~ s/$re/show_comments($c, $c->stash->{"page"});/emx) 1 123 124
36 # We don't want to precompile a page with comments so turn it off
37 1 $c->stash->{precompile_off} = 1;
38 }
39 }
40  
41 =head2 show_comments
42  
43 Forwards to L<MojoMojo::Controller::Comment>.
44  
45 =cut
46  
47 1 ▶sub show_comments {
Subroutine show_comments: called CC=1 SCAR=0.0
Pod documented
48 1 my ( $c, $page ) = @_;
49 1 $c->forward('/comment/comment');
50 1 return '<div id="comments">' . $c->view('TT')->render( $c, 'comment.tt' ) . '</div>';
51 }
52  
53 =head1 SEE ALSO
54  
55 L<MojoMojo>, L<Module::Pluggable::Ordered>
56  
57 =head1 AUTHORS
58  
59 Marcus Ramberg <mramberg@cpan.org>
60  
61 =head1 LICENSE
62  
63 This library is free software. You can redistribute it and/or modify
64 it under the same terms as Perl itself.
65  
66 =cut
67  
68 26 1;
« lib/MojoMojo/Schema/Result/Tag.pm ↑ Summary lib/MojoMojo/Formatter/File/Pod.pm »