line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
404
|
|
|
404
|
|
315241
|
use strict; |
|
404
|
|
|
|
|
1063
|
|
|
404
|
|
|
|
|
23114
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTML::FormFu::Role::Render; |
4
|
|
|
|
|
|
|
# ABSTRACT: Render role |
5
|
|
|
|
|
|
|
$HTML::FormFu::Role::Render::VERSION = '2.07'; |
6
|
404
|
|
|
404
|
|
2568
|
use HTML::FormFu::Util qw( process_attrs ); |
|
404
|
|
|
|
|
889
|
|
|
404
|
|
|
|
|
20509
|
|
7
|
404
|
|
|
404
|
|
2655
|
use Carp qw( croak ); |
|
404
|
|
|
|
|
945
|
|
|
404
|
|
|
|
|
18197
|
|
8
|
404
|
|
|
404
|
|
2695
|
use Scalar::Util qw( reftype ); |
|
404
|
|
|
|
|
994
|
|
|
404
|
|
|
|
|
18652
|
|
9
|
|
|
|
|
|
|
|
10
|
404
|
|
|
404
|
|
2791
|
use Moose::Role; |
|
404
|
|
|
|
|
1012
|
|
|
404
|
|
|
|
|
4422
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $SHARE_DIR; |
13
|
|
|
|
|
|
|
our $SHARE_ERROR; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub render { |
16
|
1127
|
|
|
1127
|
0
|
2763
|
my $self = shift; |
17
|
|
|
|
|
|
|
|
18
|
1127
|
|
33
|
|
|
7693
|
my $render_method = $ENV{HTML_FORMFU_RENDER_METHOD} || $self->render_method; |
19
|
1127
|
|
|
|
|
6386
|
my $output = $self->$render_method(@_); |
20
|
|
|
|
|
|
|
|
21
|
1127
|
|
|
|
|
3781
|
for my $proc ( @{ $self->form->get_output_processors } ) { |
|
1127
|
|
|
|
|
4306
|
|
22
|
31
|
|
|
|
|
111
|
$output = $proc->process($output); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
1127
|
|
|
|
|
7513
|
return $output; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub tt { |
29
|
7
|
|
|
7
|
0
|
24
|
my ( $self, $args ) = @_; |
30
|
|
|
|
|
|
|
|
31
|
7
|
|
100
|
|
|
55
|
$args ||= {}; |
32
|
|
|
|
|
|
|
|
33
|
7
|
100
|
|
|
|
143
|
$args->{filename} = $self->filename if !exists $args->{filename}; |
34
|
7
|
100
|
|
|
|
42
|
$args->{render_data} = $self->render_data if !exists $args->{render_data}; |
35
|
|
|
|
|
|
|
|
36
|
7
|
|
|
|
|
42
|
my $form = $self->form; |
37
|
7
|
|
|
|
|
28
|
my $share_dir = _share_dir(); |
38
|
|
|
|
|
|
|
|
39
|
7
|
|
|
|
|
20
|
my %args = %{ $self->tt_args }; |
|
7
|
|
|
|
|
81
|
|
40
|
|
|
|
|
|
|
|
41
|
7
|
50
|
|
|
|
35
|
if ( defined $share_dir ) { |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# add $share_dir to the end of INCLUDE_PATH |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$args{INCLUDE_PATH} |
46
|
|
|
|
|
|
|
= exists $args{INCLUDE_PATH} |
47
|
|
|
|
|
|
|
? ref $args{INCLUDE_PATH} eq 'ARRAY' |
48
|
2
|
|
|
|
|
12
|
? [ @{ $args{INCLUDE_PATH} }, $share_dir ] |
49
|
7
|
100
|
|
|
|
55
|
: [ $args{INCLUDE_PATH}, $share_dir ] |
|
|
50
|
|
|
|
|
|
50
|
|
|
|
|
|
|
: [$share_dir]; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
7
|
50
|
|
|
|
38
|
$args{ENCODING} = 'UTF-8' if !exists $args{ENCODING}; |
54
|
7
|
|
|
|
|
23
|
$args{RELATIVE} = 1; |
55
|
7
|
|
|
|
|
20
|
$args{RECURSION} = 1; |
56
|
|
|
|
|
|
|
|
57
|
7
|
|
|
|
|
244
|
my $tt_module = $form->tt_module; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$tt_module = $ENV{HTML_FORMFU_TT_MODULE} |
60
|
|
|
|
|
|
|
if defined $ENV{HTML_FORMFU_TT_MODULE} |
61
|
7
|
50
|
33
|
|
|
38
|
&& length $ENV{HTML_FORMFU_TT_MODULE}; |
62
|
|
|
|
|
|
|
|
63
|
7
|
|
|
|
|
17
|
my $class = $tt_module; |
64
|
7
|
|
|
|
|
27
|
$class =~ s|::|/|g; |
65
|
7
|
|
|
|
|
54
|
$class .= ".pm"; |
66
|
|
|
|
|
|
|
|
67
|
7
|
50
|
|
|
|
32
|
if ( !exists $::INC{$class} ) { |
68
|
0
|
|
|
|
|
0
|
eval { require $class }; |
|
0
|
|
|
|
|
0
|
|
69
|
0
|
0
|
|
|
|
0
|
croak $@ if $@; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
7
|
|
|
|
|
88
|
my $template = $tt_module->new( \%args ); |
73
|
|
|
|
|
|
|
|
74
|
7
|
|
|
|
|
82278
|
my $output; |
75
|
|
|
|
|
|
|
my %vars = ( |
76
|
|
|
|
|
|
|
self => $args->{render_data}, |
77
|
7
|
|
|
|
|
60
|
process_attrs => \&process_attrs, |
78
|
|
|
|
|
|
|
reftype => \&reftype, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
|
81
|
7
|
50
|
|
|
|
56
|
if ( !$template->process( $args->{filename}, \%vars, \$output ) ) { |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
0
|
my $error = $template->error; |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
0
|
|
|
0
|
if ( $error->type() eq 'file' && $error =~ /not found/i ) { |
86
|
0
|
|
|
|
|
0
|
croak <<ERROR_MESSAGE; |
87
|
|
|
|
|
|
|
$error |
88
|
|
|
|
|
|
|
The template files should have been installed somewhere in \@INC as part of |
89
|
|
|
|
|
|
|
the installation process. |
90
|
|
|
|
|
|
|
If you're using Catalyst, see Catalyst::Helper::HTML::FormFu. |
91
|
|
|
|
|
|
|
Alternatively, you can create a local copy of the files by running |
92
|
|
|
|
|
|
|
`html_formfu_deploy.pl`. |
93
|
|
|
|
|
|
|
Then set \$form->tt_args->{INCLUDE_PATH} to point to the template directory. |
94
|
|
|
|
|
|
|
ERROR_MESSAGE |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else { |
98
|
0
|
|
|
|
|
0
|
croak $error; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
7
|
|
|
|
|
43593
|
return $output; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _share_dir { |
106
|
|
|
|
|
|
|
|
107
|
7
|
100
|
|
7
|
|
29
|
return $SHARE_DIR if defined $SHARE_DIR; |
108
|
|
|
|
|
|
|
|
109
|
5
|
50
|
|
|
|
25
|
return if $SHARE_ERROR; |
110
|
|
|
|
|
|
|
|
111
|
5
|
|
|
|
|
21
|
eval { |
112
|
5
|
|
|
|
|
3560
|
require File::ShareDir; |
113
|
5
|
|
|
|
|
41360
|
require File::Spec; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# dist_dir() doesn't reliably return the directory our files are in. |
116
|
|
|
|
|
|
|
# find the path of one of our files, then get the directory from that |
117
|
|
|
|
|
|
|
|
118
|
5
|
|
|
|
|
26
|
my $path = File::ShareDir::dist_file( 'HTML-FormFu', |
119
|
|
|
|
|
|
|
'templates/tt/xhtml/form' ); |
120
|
|
|
|
|
|
|
|
121
|
5
|
|
|
|
|
1253
|
my ( $volume, $dirs, $file ) = File::Spec->splitpath($path); |
122
|
|
|
|
|
|
|
|
123
|
5
|
|
|
|
|
68
|
$SHARE_DIR = File::Spec->catpath( $volume, $dirs, '' ); |
124
|
|
|
|
|
|
|
}; |
125
|
|
|
|
|
|
|
|
126
|
5
|
50
|
|
|
|
28
|
if ($@) { |
127
|
0
|
|
|
|
|
0
|
$SHARE_DIR = undef; |
128
|
0
|
|
|
|
|
0
|
$SHARE_ERROR = 1; |
129
|
0
|
|
|
|
|
0
|
return; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
5
|
|
|
|
|
20
|
return $SHARE_DIR; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=pod |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=encoding UTF-8 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 NAME |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
HTML::FormFu::Role::Render - Render role |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 VERSION |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
version 2.07 |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 AUTHOR |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Carl Franks <cpan@fireartist.com> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Carl Franks. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
160
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |