File Coverage

lib/Egg/View/Template/GlobalParam.pm
Criterion Covered Total %
statement 6 12 50.0
branch 0 4 0.0
condition 0 6 0.0
subroutine 2 7 28.5
pod 1 1 100.0
total 9 30 30.0


line stmt bran cond sub pod time code
1             package Egg::View::Template::GlobalParam;
2             #
3             # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4             #
5             # $Id: GlobalParam.pm 337 2008-05-14 12:30:09Z lushe $
6             #
7 1     1   6 use strict;
  1         2  
  1         29  
8 1     1   6 use warnings;
  1         1  
  1         223  
9              
10             our $VERSION= '3.00';
11              
12             our %param= ();
13              
14             sub set {
15 0     0 1   my($e)= @_;
16             (
17 0     0     page_title=> sub { $e->page_title },
18 0     0     remote_addr=> sub { $e->req->addr },
19             content_type=> sub {
20 0 0 0 0     $e->req->content_type
21             || $e->config->{content_type} || 'text/html';
22             },
23             content_language=> sub {
24 0 0 0 0     $e->req->content_language
25             || $e->config->{content_language} || '';
26             },
27 0           %param
28             );
29             }
30              
31             1;
32              
33             __END__
34              
35             =head1 NAME
36              
37             Egg::View::Template::GlobalParam? - General parameter for template.
38              
39             =head1 SYNOPSIS
40              
41             use base qw/ Egg::View /;
42             use Egg::View::Template::GlobalParam;
43            
44             sub new {
45             my $view= shift->SUPER::new(@_);
46             $view->params({ Egg::View::Template::GlobalParam->set($view->e) });
47             }
48              
49             =head1 DESCRIPTION
50              
51             For global parameter setting for template.
52              
53             A global original parameter can be added from the controller etc. by setting %param.
54              
55             use Egg::View::Template::GlobalParam;
56            
57             %Egg::View::Template::GlobalParam::param= (
58             hoge => 'booo',
59             zuuu => sub { 'banban' },
60             );
61              
62             =head1 METHODS
63              
64             =head2 set ([PROJECT_CONTEXT])
65              
66             The content of the set parameter is returned.
67              
68             =head1 SEE ALSO
69              
70             L<Egg::Release>,
71             L<Egg::View>,
72             L<Egg::View::Mason>,
73             L<Egg::View::HT>,
74              
75             =head1 AUTHOR
76              
77             Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
78              
79             =head1 COPYRIGHT AND LICENSE
80              
81             Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>.
82              
83             This library is free software; you can redistribute it and/or modify
84             it under the same terms as Perl itself, either Perl version 5.8.6 or,
85             at your option, any later version of Perl 5 you may have available.
86              
87             =cut
88