| 1 | package Tree::Navigator::View::TT2; | ||||||||||
| 2 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Template; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | 1 | extends 'Tree::Navigator::View'; | |||||||||
| 12 | 1 | has 'tt' => ( is => 'ro', isa => 'Template' ); | |||||||||
| 13 | 1 | has 'input' => ( is => 'ro' ); | |||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | around 'BUILDARGS' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 16 | 0 | my $parent_buildargs = shift; | |||||||||
| 17 | 0 | my $class = shift; | |||||||||
| 18 | 0 | my $input = shift; | |||||||||
| 19 | 0 | my $template_args = $class->$parent_buildargs(@_); | |||||||||
| 20 | |||||||||||
| 21 | 0 | return {tt => Template->new(%$template_args), | |||||||||
| 22 | input => $input}; | ||||||||||
| 23 | |||||||||||
| 24 | # TODO: also take args from $tn->config | ||||||||||
| 25 | 1 | }; | |||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | sub render { | ||||||||
|
Subroutine
render: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 30 | 0 | my ($self, $node, $request) = @_; | |||||||||
| 31 | |||||||||||
| 32 | 0 | my $values = { node => $node, | |||||||||
| 33 | data => $node->data, | ||||||||||
| 34 | request => $request }; | ||||||||||
| 35 | 0 | ▶ | $self->tt->process($self->input, $values, \my $output) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | or return [500, ['Content-type' => 'text/plain'], | ||||||||||
| 37 | [$self->tt->error->as_string] ]; | ||||||||||
| 38 | |||||||||||
| 39 | 0 | return [200, ['Content-type' => 'text/html'], [$output] ]; | |||||||||
| 40 | |||||||||||
| 41 | # TODO: extend API to choose other content-type and maybe add other headers | ||||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | 1 | 1; # end of package Tree::Navigator::View::TT2 | |||||||||
| 46 | |||||||||||
| 47 | __END__ | ||||||||||