This file is indexed.

/usr/share/perl5/Catalyst/View/Petal.pm is in libcatalyst-view-petal-perl 0.03-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package Catalyst::View::Petal;

use strict;
use base 'Catalyst::View';

use Petal;

our $VERSION = '0.03';

=head1 NAME

Catalyst::View::Petal - Petal View Class

=head1 SYNOPSIS

    # use the helper
    create.pl view Petal Petal

    # lib/MyApp/View/Petal.pm
    package MyApp::View::Petal;

    use base 'Catalyst::View::Petal';

    __PACKAGE__->config(
        input              => 'XML',
        output             => 'XML',
        error_on_undef_var => 0
    );

    1;

    # Meanwhile, maybe in an 'end' action
    $c->forward('MyApp::View::Petal');


=head1 DESCRIPTION

This is the C<Petal> view class. Your subclass should inherit from this
class.

=head2 METHODS

=over 4

=item process

Renders the template specified in C<< $c->stash->{template} >> or C<<
$c->request->match >>.
Template variables are set up from the contents of C<< $c->stash >>,
augmented with C<base> set to C<< $c->req->base >>, C<c> to C<$c> and
C<name> to C<< $c->config->{name} >>.  Output is stored in
C<< $c->response->body >>.

=cut

sub process {
    my ( $self, $c ) = @_;

    my $file = $c->stash->{template} || $c->req->match;

    unless ($file) {
        $c->log->debug('No template specified for rendering') if $c->debug;
        return 0;
    }

    my %options = (
        base_dir => [ $c->config->{root}, $c->config->{root} . "/base" ],
        file     => $file
    );

    unless ( $c->debug ) {
        $options{debug_dump}         = 0;
        $options{error_on_undef_var} = 0;
    }

    my $process = {
        base => $c->req->base,
        c    => $c,
        name => $c->config->{name},
        %{ $c->stash }
    };

    $c->log->debug(qq/Rendering template "$file"/) if $c->debug;

    my $petal = Petal->new( %options, %{ $self->config } );

    my $body;

    eval { $body = $petal->process($process) };

    if ( my $error = $@ ) {
        chomp $error;
        $error = qq/Couldn't render template "$file". Error: "$error"/;
        $c->log->error($error);
        $c->error($error);
        return 0;
    }

    unless ( $c->response->headers->content_type ) {
        $c->res->headers->content_type('text/html; charset=utf-8');
    }

    $c->response->body($body);

    return 1;
}

=item config

This allows your view subclass to pass additional settings to the
Petal config hash.

=back

=head1 SEE ALSO

L<Petal>, L<Catalyst>, L<Catalyst::Base>.

=head1 AUTHOR

Christian Hansen, C<ch@ngmedia.com>

=head1 COPYRIGHT

This program is free software, you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut

1;