The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Eve::HttpResource::Template - a simple HTTP resource with a template.

SYNOPSIS

    use Eve::HttpResource::Template;

    # Bind it to an URL using the HTTP resource dispatcher. See
    # B<Eve::HttpDispatcher> class.

    my $resource = Eve::HttpResource::Template->new(
        response => $response,
        session_constructor => $session_constructor,
        dispatcher => $dispatcher,
        template => $template,
        template_file => 'template.html',
        template_var_hash => {'some_var' => 1, 'other_var' => 2},
        require_auth => 1,
        content_type => 'text/plain',
        charset => 'CP1251',
        text_var_hash => $text_var_hash);

    $dispatcher->bind(
        name => 'some_unique_name',
        pattern => '/some_uri',
        base_uri => $some_base_uri,
        resource_constructor => sub {
            return $resource;
        });

DESCRIPTION

Eve::HttpResource::Template is a simple HTTP resource that only displays a parsed template. All the templates have the following objects available in their scope:

session

an instance of the Eve::Session object for the current user,

Constructor arguments

response

an HTTP response object,

session_constructor

a reference to a subroutine that returns a session object,

dispatcher

an HTTP dispatcher object,

template

a template object,

template_file

a template file name,

template_var_hash

(optional) a hash of variables to be passed to the processed template, defaults to an empty hash,

require_auth

(optional) if a user is not authenticated, throw a Eve::Exception::Http::401Unauthorized,

content_type

(optional) response content-type, defaults to text/html,

charset

(optional) response character set, defaults to UTF-8.

METHODS

init()

SEE ALSO

Eve::HttpDispatcher
Eve::HttpResource
Eve::Template

LICENSE AND COPYRIGHT

Copyright 2012 Igor Zinovyev.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

AUTHOR

Igor Zinovyev