File: TestAppTName.pm

package info (click to toggle)
libcgi-application-plugin-tt-perl 1.05%2B~cs1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 440 kB
  • sloc: perl: 806; makefile: 17
file content (118 lines) | stat: -rw-r--r-- 2,498 bytes parent folder | download | duplicates (5)
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
package TestAppTName;

use strict;

use base qw(TestAppBase);

sub test_mode {
    my $self = shift;

    $self->tt_params(template_param_hash => 'template param hash');
    $self->tt_params({template_param_hashref => 'template param hashref'});


    my $tt_vars = {
                    template_var => 'template param',
                    template_name => $self->tt_template_name,
    };

    return $self->tt_process($tt_vars);
}

sub tt_pre_process {
    my $self = shift;
    my $file = shift;
    my $vars = shift;

    $vars->{pre_process_var} = 'pre_process param';
}

sub tt_post_process {
    my $self    = shift;
    my $htmlref = shift;

    $$htmlref =~ s/post_process_var/post_process param/;
}

package TestAppTName::CustName;

use strict;

use TestAppTName;
@TestAppTName::CustName::ISA = qw(TestAppTName);

sub cgiapp_init {
    my $self = shift;

    $self->tt_config(
              TEMPLATE_OPTIONS => {
                        INCLUDE_PATH => 't',
                        POST_CHOMP   => 1,
                        DEBUG => 1,
              },
              TEMPLATE_NAME_GENERATOR => sub { return 'TestAppTName/test.tmpl' },
    );
}

package TestAppTName::NoVars;

use strict;

@TestAppTName::NoVars::ISA = qw(TestAppTName);

sub test_mode {
    my $self = shift;

    $self->tt_params(template_param_hash => 'template param hash');
    $self->tt_params({template_param_hashref => 'template param hashref'});

    return $self->tt_process('TestAppTName/test_mode.tmpl');
}


package TestAppTName::NoNameNoVars;

use strict;

@TestAppTName::NoNameNoVars::ISA = qw(TestAppTName);

sub test_mode {
    my $self = shift;

    $self->tt_params(template_param_hash => 'template param hash');
    $self->tt_params({template_param_hashref => 'template param hashref'});

    return $self->tt_process;
}

package TestAppTName::UpLevel;

use strict;

@TestAppTName::UpLevel::ISA = qw(TestAppTName);

sub test_mode {
    my $self = shift;

    $self->tt_params(template_param_hash => 'template param hash');
    $self->tt_params({template_param_hashref => 'template param hashref'});

    my $tt_vars = {
                    template_var => 'template param',
                    template_name => $self->call_tt_template_name,
    };

    return $self->call_tt_process($tt_vars);
}

sub call_tt_process {
    my $self = shift;
    return $self->tt_process($self->tt_template_name(1), @_);
}

sub call_tt_template_name {
    my $self = shift;
    return $self->tt_template_name(1);
}

1;