File: StoreOne.pm

package info (click to toggle)
libtext-micromason-perl 2.13-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 624 kB
  • ctags: 180
  • sloc: perl: 3,222; makefile: 23
file content (87 lines) | stat: -rw-r--r-- 1,802 bytes parent folder | download | duplicates (8)
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
package Text::MicroMason::StoreOne;

######################################################################

sub create {
  my ( $class, %options ) = @_;
  my @compile; 
  if ( my $file = delete $options{filename} ) {
    @compile = ( 'file' => $file );
  } elsif ( my $string = delete $options{text} ) {
    @compile = ( 'text' => $string );
  } 
  my $self = $class->NEXT('create', %options);
  $self->compile( @compile ) if @compile;
  $self;
}

sub compile {
  my $self = shift;
  my $sub = $self->NEXT('compile', @_);
  $self->{last_compile} = $sub;
}

sub execute_again {
  my $self = shift;
  my $sub = $self->{last_compile} 
	or $self->croak_msg("No template has been compiled yet");
  &$sub( @_ );
}

######################################################################

1;

__END__

######################################################################

=head1 NAME

Text::MicroMason::StoreOne - mixin class intended for use with Text::MicroMason::Base

=head1 DESCRIPTION

This mixin class ...


=head2 Public Methods

=over 4

=item compile()

Caches a reference to the most-recently compiled subroutine in the Mason object.

=item execute_again()

Executes the most-recently compiled template and returns the results.

Optionally accepts a filehandle to print the results to.

  $template->output( print_to => *STDOUT );

=back


=head2 Private Methods

=over 4

=item create()

Creates a new Mason object. If a string or filename parameter is supplied, the corresponding template is compiled.

=back

=head1 SEE ALSO

For an overview of this templating framework, see L<Text::MicroMason>.

This is a mixin class intended for use with L<Text::MicroMason::Base>.

For distribution, installation, support, copyright and license 
information, see L<Text::MicroMason::Docs::ReadMe>.

=cut