App::TemplateServer::Provider::HTML::Template - serve HTML::Template templates with App::TemplateServer


App-TemplateServer-Provider-HTML-Template documentation Contained in the App-TemplateServer-Provider-HTML-Template distribution.

Index


Code Index:

Top

App::TemplateServer::Provider::HTML::Template - serve HTML::Template templates with App::TemplateServer

SYNOPSIS

Top

Use HTML::Template templates with App::TemplateServer.

   template-server --provider HTML::Template --docroot /your/templates

See template-server and App::TemplateServer for details.

AUTHOR AND COPYRIGHT

Top


App-TemplateServer-Provider-HTML-Template documentation Contained in the App-TemplateServer-Provider-HTML-Template distribution.

package App::TemplateServer::Provider::HTML::Template;
use Moose;
use HTML::Template;
use Method::Signatures;

our $VERSION = '0.01';

with 'App::TemplateServer::Provider::Filesystem';

method render_template($template_file, $context){
    my $template = HTML::Template->new(
        path     => scalar $self->docroot,
        filename => $template_file,
    );
    
    my %data = %{$context->data||{}};
    for my $var (keys %data){
        my $value = $data{$var};
        $template->param($var => $value);
    }
    
    return $template->output;
};

1;

__END__