line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Template::MicroTemplate; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Text::MicroTemplate engine for Dancer |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
683063
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
169
|
|
6
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
97
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
2791
|
use Text::MicroTemplate::File; |
|
3
|
|
|
|
|
18909
|
|
|
3
|
|
|
|
|
160
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
32
|
use vars '$VERSION'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
169
|
|
11
|
3
|
|
|
3
|
|
17
|
use base 'Dancer::Template::Abstract'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
3164
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = '1.0.0'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $_engine; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
2
|
|
|
2
|
1
|
91
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
5
|
my %mt_cfg = (%{ $self->config }); |
|
2
|
|
|
|
|
22
|
|
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
53
|
$_engine = Text::MicroTemplate::File->new(%mt_cfg); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub render($$$) { |
26
|
2
|
|
|
2
|
1
|
4971
|
my ($self, $template, $tokens) = @_; |
27
|
|
|
|
|
|
|
|
28
|
2
|
50
|
33
|
|
|
77
|
die "'$template' is not a regular file" |
29
|
|
|
|
|
|
|
if ref($template) || (!-f $template); |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
6
|
my $content = ""; |
32
|
2
|
|
|
|
|
15
|
$content = $_engine->render_file($template, $tokens)->as_string; |
33
|
2
|
|
|
|
|
4241
|
return $content; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 NAME |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Dancer::Template::MicroTemplate - Text::MicroTemplate engine for Dancer |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This class is an interface between Dancer's template engine abstraction layer |
45
|
|
|
|
|
|
|
and the L module. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
In order to use this engine, set the following setting as the following: |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
template: micro_template |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This can be done in your config.yml file or directly in your app code with the |
52
|
|
|
|
|
|
|
C keyword. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SEE ALSO |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
L, L |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 AUTHOR |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This module has been written by Franck Cuny and James Aitken |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 LICENSE |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
65
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |