MojoMojo::Formatter::Comment - Include comments on your page.


MojoMojo documentation Contained in the MojoMojo distribution.

Index


Code Index:

NAME

Top

MojoMojo::Formatter::Comment - Include comments on your page.

DESCRIPTION

Top

This is a hook for the page comment functionality. It allows a comment box to be placed anywhere on your page through the {{comments}} tag.

METHODS

Top

format_content_order

Format order can be 1-99. The Comment formatter runs on 91.

format_content

Calls the formatter. Takes a ref to the content as well as the context object.

show_comments

Forwards to MojoMojo::Controller::Comment.

SEE ALSO

Top

MojoMojo, Module::Pluggable::Ordered

AUTHORS

Top

Marcus Ramberg <mramberg@cpan.org>

LICENSE

Top

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.


MojoMojo documentation Contained in the MojoMojo distribution.
package MojoMojo::Formatter::Comment;

use parent qw/MojoMojo::Formatter/;

sub format_content_order { 91 }

sub format_content {
    my ( $class, $content, $c, $self ) = @_;
    my $re=$class->gen_re('comments');
    if ( $$content =~ s|$re|show_comments($c,$c->stash->{page})|xme ) {
        # We don't want to precompile a page with comments so turn it off
        $c->stash->{precompile_off} = 1;
    }
}

sub show_comments {
    my ( $c, $page ) = @_;
    $c->forward('/comment/comment');
    return '<div id="comments">' . $c->view('TT')->render( $c, 'comment.tt' ) . '</div>';
}

1;