line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Alloy::Stream; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Template::Alloy::Stream - Stream role - allows for playing out the AST and printing straight to file handle |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
114
|
|
10
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
97
|
|
11
|
3
|
|
|
3
|
|
16
|
use Template::Alloy; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
22
|
|
12
|
3
|
|
|
3
|
|
16
|
use Template::Alloy::Play; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
724
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = $Template::Alloy::VERSION; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
0
|
0
|
sub new { die "This class is a role for use by packages such as Template::Alloy" } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
###----------------------------------------------------------------### |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub stream_tree { |
21
|
2779
|
|
|
2779
|
1
|
4996
|
my ($self, $tree) = @_; |
22
|
|
|
|
|
|
|
|
23
|
2779
|
|
|
|
|
8418
|
local $Template::Alloy::Play::DIRECTIVES->{'CLEAR'} = \&stream_CLEAR; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# node contains (0: DIRECTIVE, |
26
|
|
|
|
|
|
|
# 1: start_index, |
27
|
|
|
|
|
|
|
# 2: end_index, |
28
|
|
|
|
|
|
|
# 3: parsed tag details, |
29
|
|
|
|
|
|
|
# 4: sub tree for block types |
30
|
|
|
|
|
|
|
# 5: continuation sub trees for sub continuation block types (elsif, else, etc) |
31
|
|
|
|
|
|
|
# 6: flag to capture next directive |
32
|
2779
|
|
|
|
|
5130
|
for my $node (@$tree) { |
33
|
|
|
|
|
|
|
### text nodes are just the bare text |
34
|
4636
|
100
|
|
|
|
10654
|
if (! ref $node) { |
35
|
659
|
50
|
|
|
|
3000
|
print $node if defined $node; |
36
|
659
|
|
|
|
|
1667
|
next; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
3977
|
100
|
66
|
|
|
10891
|
print $self->debug_node($node) if $self->{'_debug_dirs'} && ! $self->{'_debug_off'}; |
40
|
|
|
|
|
|
|
|
41
|
3977
|
|
|
|
|
5195
|
my $out = ''; |
42
|
3977
|
|
|
|
|
17474
|
$Template::Alloy::Play::DIRECTIVES->{$node->[0]}->($self, $node->[3], $node, \$out); |
43
|
3858
|
|
|
|
|
19887
|
print $out; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub stream_CLEAR { |
48
|
1
|
|
|
1
|
0
|
4
|
my ($self, $undef, $node) = @_; |
49
|
1
|
|
|
|
|
6
|
$self->throw('stream', 'Cannot use CLEAR directive when STREAM is being used', $node); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
###----------------------------------------------------------------### |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |