The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

HTML::ForumCode::Cookbook::Recipe1 - Catalyst Controller

SYNOPSIS

package MyApp::Controller::ForumCode;
# vim: ts=8 sts=4 et sw=4 sr sta
use strict;
use warnings;
use parent 'Catalyst::Controller';

use JSON::Any;
use HTML::ForumCode;

sub preview : Local {
    my ($self, $c) = @_;
    my $tt_forum = HTML::ForumCode->new();
    my $msg_source = $c->request->param('msg_source');

    my $j = JSON::Any->new;
    my $json = $j->to_json(
        {
            'formatted' =>
                $tt_forum->forumcode(
                    $msg_source
                )
        }
    );

    $c->response->body( $json );
    return;
}

1;

DESCRIPTION

This recipe provides a Catalyst controller class that will take HTML::ForumCode markup via the msg_source parameter and return the formatted HTML in the formatted key of a JSON response.

AUTHOR

Chisel Wright <chiselwright@users.berlios.de>

LICENSE

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