lib/MojoMojo/View/TT.pm

filter: Statementstmt 100% 33 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 100% 42 / 42 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/MojoMojo/View/JSON.pm ↑ Summary
1 package MojoMojo::View::TT;
2  
3 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use parent 'Catalyst::View::TT';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 35 ▶use Template::Constants qw( :debug );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 35 ▶use Class::C3 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 35 ▶use Path::Class qw/dir/;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 35 __PACKAGE__->config->{PRE_CHOMP} = 2;
27 35 __PACKAGE__->config->{POST_CHOMP} = 2;
28 35 __PACKAGE__->config->{CONTEXT} = undef;
29 35 __PACKAGE__->config->{TEMPLATE_EXTENSION} = '.tt';
30 35 __PACKAGE__->config->{PRE_PROCESS} = 'global.tt';
31 35 __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 35 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
40 35 my $class = shift;
41  
42 35 my ( $c, $arg_ref ) = @_;
43  
44 $class->config->{INCLUDE_PATH}=[
45 $c->config->{root},
46 35 dir($c->config->{root})->subdir('base'),
47 ];
48  
49 35 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 140 ▶sub _nav_filter {
Subroutine _nav_filter: called CC=1 SCAR=0.0
60 140 my ( $context, @args ) = @_;
61  
62 140 my $c = $context->stash()->{c};
63  
64 140 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
65 140 my $html = shift;
66  
67 140 my $uri = $c->req->uri;
68  
69 140 $html =~ s{<a([^>]+)(href="\Q$uri\E")}{<a class="navOn" $1$2};
70  
71 140 return $html;
72 140 };
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 35 1;
« lib/MojoMojo/View/JSON.pm ↑ Summary