line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Template flute engine for Dancer2 |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Dancer2::Template::TemplateFlute; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
254997
|
use Carp qw/croak/; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
298
|
|
6
|
3
|
|
|
3
|
|
1124
|
use Dancer2::Core::Types; |
|
3
|
|
|
|
|
23659
|
|
|
3
|
|
|
|
|
1667
|
|
7
|
3
|
|
|
3
|
|
4618
|
use Template::Flute; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Moo; |
10
|
|
|
|
|
|
|
with 'Dancer2::Core::Role::Template'; |
11
|
|
|
|
|
|
|
use namespace::clean; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub default_tmpl_ext {'html'} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub render { |
16
|
|
|
|
|
|
|
my ( $self, $template, $tokens ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
( ref $template || -f $template ) |
19
|
|
|
|
|
|
|
or croak "$template is not a regular file or reference"; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $content = ''; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $args = { |
24
|
|
|
|
|
|
|
template_file => $template, |
25
|
|
|
|
|
|
|
scopes => 1, |
26
|
|
|
|
|
|
|
auto_iterators => 1, |
27
|
|
|
|
|
|
|
values => $tokens, |
28
|
|
|
|
|
|
|
filters => $self->config->{filters}, |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
$args->{specification_file} |
31
|
|
|
|
|
|
|
= $tokens->{settings}->{views} . '/' . $tokens->{specification_file} |
32
|
|
|
|
|
|
|
if $tokens->{specification_file}; |
33
|
|
|
|
|
|
|
$args->{specification_file} |
34
|
|
|
|
|
|
|
||= Template::Flute::Utils::derive_filename( $template, '.xml' ); |
35
|
|
|
|
|
|
|
$args->{specification} = q{} |
36
|
|
|
|
|
|
|
unless -f $args->{specification_file}; |
37
|
|
|
|
|
|
|
my $flute = Template::Flute->new(%$args); |
38
|
|
|
|
|
|
|
$content = $flute->process() |
39
|
|
|
|
|
|
|
or croak $flute->error; |
40
|
|
|
|
|
|
|
return $content; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |