line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoMojo::View::TT; |
2
|
|
|
|
|
|
|
|
3
|
35
|
|
|
35
|
|
12088
|
use strict; |
|
35
|
|
|
|
|
83
|
|
|
35
|
|
|
|
|
1022
|
|
4
|
35
|
|
|
35
|
|
304
|
use parent 'Catalyst::View::TT'; |
|
35
|
|
|
|
|
110
|
|
|
35
|
|
|
|
|
207
|
|
5
|
35
|
|
|
35
|
|
1627313
|
use Template::Constants qw( :debug ); |
|
35
|
|
|
|
|
193
|
|
|
35
|
|
|
|
|
6366
|
|
6
|
35
|
|
|
35
|
|
19332
|
use Class::C3 (); |
|
35
|
|
|
|
|
51949
|
|
|
35
|
|
|
|
|
796
|
|
7
|
35
|
|
|
35
|
|
254
|
use Path::Class qw/dir/; |
|
35
|
|
|
|
|
110
|
|
|
35
|
|
|
|
|
8704
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
MojoMojo::V::TT - Template Toolkit views for MojoMojo |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# in some action |
16
|
|
|
|
|
|
|
$c->forward('MojoMojo::V::TT'); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Subclass of L<Catalyst::View::TT>. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#__PACKAGE__->config->{DEBUG} = DEBUG_UNDEF; |
26
|
|
|
|
|
|
|
__PACKAGE__->config->{PRE_CHOMP} = 2; |
27
|
|
|
|
|
|
|
__PACKAGE__->config->{POST_CHOMP} = 2; |
28
|
|
|
|
|
|
|
__PACKAGE__->config->{CONTEXT} = undef; |
29
|
|
|
|
|
|
|
__PACKAGE__->config->{TEMPLATE_EXTENSION} = '.tt'; |
30
|
|
|
|
|
|
|
__PACKAGE__->config->{PRE_PROCESS} = 'global.tt'; |
31
|
|
|
|
|
|
|
__PACKAGE__->config->{FILTERS} = { nav => [ \&_nav_filter, 1 ] }; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 new |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Contructor for TT View. Can configure paths to .tt files here. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub new { |
40
|
35
|
|
|
35
|
1
|
2943376
|
my $class = shift; |
41
|
|
|
|
|
|
|
|
42
|
35
|
|
|
|
|
139
|
my ( $c, $arg_ref ) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$class->config->{INCLUDE_PATH}=[ |
45
|
|
|
|
|
|
|
$c->config->{root}, |
46
|
35
|
|
|
|
|
192
|
dir($c->config->{root})->subdir('base'), |
47
|
|
|
|
|
|
|
]; |
48
|
|
|
|
|
|
|
|
49
|
35
|
|
|
|
|
12095
|
return $class->next::method(@_); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 _nav_filter |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Add a "navOn" class to all HTML links that point to the current request URI. |
55
|
|
|
|
|
|
|
Use by navbar TT code. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _nav_filter { |
60
|
140
|
|
|
140
|
|
6706
|
my ( $context, @args ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
140
|
|
|
|
|
576
|
my $c = $context->stash()->{c}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return sub { |
65
|
140
|
|
|
140
|
|
454
|
my $html = shift; |
66
|
|
|
|
|
|
|
|
67
|
140
|
|
|
|
|
751
|
my $uri = $c->req->uri; |
68
|
|
|
|
|
|
|
|
69
|
140
|
|
|
|
|
9482
|
$html =~ s{<a([^>]+)(href="\Q$uri\E")}{<a class="navOn" $1$2}; |
70
|
|
|
|
|
|
|
|
71
|
140
|
|
|
|
|
4100
|
return $html; |
72
|
140
|
|
|
|
|
1345
|
}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SEE ALSO |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L<Catalyst::View::TT> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHORS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Marcus Ramberg C<marcus@thefeed.no> |
82
|
|
|
|
|
|
|
David Naughton C<naughton@umn.edu> |
83
|
|
|
|
|
|
|
Dave Rolsky C<autarch@urth.org> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 LICENSE |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify |
88
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |