Marquee Marquee::Dynamic - Dynamic server

TABLE OF CONTENTS

NAME

Marquee::Dynamic - Dynamic server

SYNOPSIS

my $dynamic = Maruqee::dynamic->new;
$dynamic->add_handler(ep => Marquee::SSIHandler::EP->new());
$dynamic->serve('/path/to/template.html.ep');

DESCRIPTION

Marquee::Dynamic represents dynamic page server.

ATTRIBUTES

Marquee::Dynamic implements the following attributes.

handlers

An hash ref that contains Server side include handlers. The hash keys corresponds to the last extensions of templates.

$dynamic->handlers->{myhandler} = Marquee::SSIHandler::MyHandler->new;

handler_re

A regex pattern to detect handler extensions. This is automatically generated.

my $regex = $dynamic->handler_re;

roots

Root array for searching templates.

$dynamic->roots(['path/to/dir1', 'path/to/dir1']);
my $roots = $dynamic->roots;

INSTANCE METHODS

Marquee::Dynamic implements the following instance methods.

add_handler

Adds "handlers" entry. The first argument is corresponds to the last extensions of templates. Second argument must be a Marquee::SSIHandler sub class instance. See Marquee::SSIHandler::EPL as an example.

$dynamic->add_handler(myhandler => Marquee::SSIHandler::MyHandler->new);

Following file will be available.

template.html.myhandler

render

Render given file of path as SSI template and returns the result. This method auto detect the handler with the file name unless second argument is given. Note that the renderer extension is NOT to be suffixed automatically.

# render /path/to/template.html.ep by ep handler
my $result = $dynamic->render('/path/to/template.html.ep');

# render /path/to/template.html.ep by epl handler
my $result = $dynamic->render('/path/to/template.html.ep', 'epl');

# render /path/to/template.html by ep handler
my $result = $dynamic->render('/path/to/template2.html', 'ep');

search

Searches for SSI template for given path and returns the path with SSI extension if exists. The search is made within the directories out of /roots attribute.

my $path = $dynamic->search('./tmpl.html'); # /path/to/document_root/tmpl.html.ep
my $path = $dynamic->search('/path/to/tmpl.html'); # /path/to/tmpl.html.ep

serve

Serves dynamic page.

$dynamic->serve('/path/to/template.html.ep');

SEE ALSO

Marquee, Mojolicious