Jifty/View/Declare/BaseClass.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 54 CC 1 SCAR 6.9
CC
1
Cov
0%
use_mason_wrapper
2.0
Static
2.0
Action
2.0
CRAP 2.0
1 package Jifty::View::Declare::BaseClass;
2  
3 use strict;
4 use warnings;
5 use base qw/Exporter Jifty::View::Declare::Helpers/;
6  
7 use Jifty::View::Declare::Helpers;
8  
9  
10 our @EXPORT = ( @Jifty::View::Declare::Helpers::EXPORT);
11  
12 =head1 NAME
13  
14 Jifty::View::Declare::BaseClass - Base class for Template::Declare views
15  
16 =head1 DESCRIPTION
17  
18 This class provides a base class for your L<Template::Declare> derived view classes.
19  
20 =head1 METHODS
21  
22 =head2 use_mason_wrapper
23  
24 Call this function in your view class to use your mason wrapper for L<Template::Declare> templates,
25 something like:
26  
27 package TestApp::View;
28 use Jifty::View::Declare -base;
29 __PACKAGE__->use_mason_wrapper;
30  
31 If you don't use mason then you can define a C<wrapper> function in the view class to override
32 default page layouts. Default TD wrapper defined in L<Jifty::View::Declare::Helpers>.
33  
34 =cut
35  
36 sub use_mason_wrapper {
37 my $class = shift;
38 no strict 'refs';
39 no warnings 'redefine';
40 *{ $class . '::wrapper' } = sub {
41 my $code = shift;
42 my $args = shift || {};
43  
44 my $interp = Jifty->handler->view('Jifty::View::Mason::Handler')->interp;
45 my $req = $interp->make_request( comp => '/_elements/wrapper' );
46 my $wrapper = $interp->load("/_elements/wrapper");
47 local $HTML::Mason::Commands::m = $req;
48 $req->comp(
49 {content => sub {$code->()}},
50 $wrapper,
51 %{$args}
52 );
53 }
54 }
55  
56 use Attribute::Handlers;
57 our (%Static, %Action);
58  
59 =head1 ATTRIBUTES
60  
61 clkao owes documentation as to the meaning of this and when it would be acceptable to use it.
62  
63 =head2 Static
64  
65 TODO Document this...
66  
67 This is part of the client-caching system being developed for Perl to allow you to translate templates into JavaScript running on the client.
68  
69 This function allows a developer to mark a L<Template::Declare> template as static (unchanging), so that the compiled version can be cached on the client side and inserted with javascript.
70  
71 =cut
72  
73 sub Static :ATTR(CODE,BEGIN) { $Static{$_[2]}++; }
74  
75 =head2 Action
76  
77 TODO Document this...
78  
79 This is part of the client-caching system being developed for Perl to allow you to translate templates into JavaScript running on the client.
80  
81 This function allows a developer to mark a Template::Declare template as an action.
82  
83 =cut
84  
85 sub Action :ATTR(CODE,BEGIN) { $Action{$_[2]}++; }
86  
87 =head1 SEE ALSO
88  
89 L<Jifty::View::Declare>, L<Template::Declare>, L<Jifty::View::Declare::Helpers>
90  
91 =head1 LICENSE
92  
93 Jifty is Copyright 2005-2010 Best Practical Solutions, LLC.
94 Jifty is distributed under the same terms as Perl itself.
95  
96 =cut
97  
98 1;