File: TestAppCallback.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 (53 lines) | stat: -rw-r--r-- 959 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
package TestAppCallback;

use strict;

use base qw(TestAppBase);

__PACKAGE__->add_callback('tt_pre_process', 
    sub {
        my $self = shift;
        my $file = shift;
        my $vars = shift;

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

__PACKAGE__->add_callback('tt_post_process', 
    sub {
        my $self    = shift;
        my $htmlref = shift;

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

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.'
    };

    return $self->tt_process(\*DATA, $tt_vars);
}

1;

# The test template file is below in the DATA segment

__DATA__

[% template_var %]
[% template_param_hash %]
[% template_param_hashref %]

[% pre_process_var %]

post_process_var