NAME

MojoX::Renderer - Renderer

SYNOPSIS

use MojoX::Renderer;

my $renderer = MojoX::Renderer->new;

DESCRIPTION

MojoX::Renderer is a MIME type based renderer.

ATTRIBUTES

default_handler

my $default = $renderer->default_handler;
$renderer   = $renderer->default_handler('epl');

handler

my $handler = $renderer->handler;
$renderer   = $renderer->handler({epl => sub { ... }});

Returns a hashref of handlers if called without arguments. Returns the invocant if called with arguments. Keys are file extensions and values are coderefs.

precedence

my $precedence = $renderer->precedence;
$renderer      = $renderer->precedence(qw/epl tt mason/);

types

my $types = $renderer->types;
$renderer = $renderer->types(MojoX::Types->new);

Returns a MojoX::Types object if called without arguments. Returns the invocant if called with arguments.

root

my $root  = $renderer->root;
$renderer = $renderer->root('/foo/bar/templates');

Return the root file system path where templates are stored if called without arguments. Returns the invocant if called with arguments.

METHODS

MojoX::Types inherits all methods from Mojo::Base and implements the follwing the ones.

add_handler

$renderer = $renderer->add_handler(epl => sub { ... });

render

my $success  = $renderer->render($c);

$c->stash->{partial} = 1;
my $output = $renderer->render($c);