App::TemplateServer::Provider::Null - a test template provider


App-TemplateServer documentation Contained in the App-TemplateServer distribution.

Index


Code Index:

NAME

Top

App::TemplateServer::Provider::Null - a test template provider

SYNOPSIS

Top

This doesn't do anything useful. It's just example code for you to poke at.

Try it out like this:

  template-server --provider Null --data /path/to/some/yaml

Then visit http://localhost:4000/test and you can see the YAML.

METHODS

Top

list_templates

render_template

Both implemented as App::TemplateServer::Provider suggests.

SEE ALSO

Top

App::TemplateServer

App::TemplateServer::Provider


App-TemplateServer documentation Contained in the App-TemplateServer distribution.

package App::TemplateServer::Provider::Null;
use Moose;
use Method::Signatures;
use YAML::Syck;

with 'App::TemplateServer::Provider';

method list_templates {
    return qw/this is a test/;
};

method render_template($template, $context){
    my $data = Dump({%$context, docroot => [$self->docroot]});
    $data =~ s/&/&/g;
    $data =~ s/</&lt;/g;
    $data =~ s/>/&gt;/g;
    
    my $res = "<p>This is a template called $template</p>";
    $res .= "<p>Here is all the data I know about:<br />";
    $res .= "<blockquote><pre>$data</pre></blockquote></p>";

    return $res;
};

1;
__END__