| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#=============================================================================== |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# DESCRIPTION: maintain collection of files and templates |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# AUTHOR: Aliaksandr P. Zahatski, <zahatski@gmail.com> |
|
6
|
|
|
|
|
|
|
#=============================================================================== |
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Plosurin::Context - maintain collection of files and templates |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
new Plosurin::Context( <Plo::File1>,<Plo::File2> ); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Plosurin::Context - maintain collection of files and templates |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# while export is going |
|
22
|
|
|
|
|
|
|
package Plosurin::Context; |
|
23
|
2
|
|
|
2
|
|
506
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
61
|
|
|
24
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
658
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 new |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#init colection |
|
30
|
|
|
|
|
|
|
new Plosurin::Context( <Plo::File1>,<Plo::File2> ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
|
35
|
4
|
|
|
4
|
1
|
25
|
my $class = shift; |
|
36
|
4
|
|
33
|
|
|
40
|
bless( { src => [@_] }, ref($class) || $class ); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 name2tmpl |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return hash all templates |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
=cut |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub name2tmpl { |
|
48
|
2
|
|
|
2
|
1
|
5
|
my $self = shift; |
|
49
|
2
|
|
|
|
|
4
|
my %res = (); |
|
50
|
2
|
|
|
|
|
4
|
foreach my $file ( @{ $self->{src} } ) { |
|
|
2
|
|
|
|
|
10
|
|
|
51
|
2
|
|
|
|
|
8
|
for ( $file->templates ) { |
|
52
|
4
|
|
|
|
|
10
|
my $full_name = $file->namespace . $_->name; |
|
53
|
4
|
|
|
|
|
14
|
$res{$full_name} = $_; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
} |
|
56
|
2
|
|
|
|
|
20
|
\%res; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 get_template_by_name |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
get by .name -> absolute -> rerurn ref to template |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_template_by_name { |
|
66
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
67
|
1
|
|
50
|
|
|
4
|
my $name = shift || return undef; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#get current namespace |
|
70
|
1
|
50
|
|
|
|
6
|
if ( $name =~ /^\./ ) { |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#uless defined namespace |
|
73
|
|
|
|
|
|
|
#get from first File |
|
74
|
1
|
|
33
|
|
|
4
|
my $namespace = $self->{namespace} || $self->{src}->[0]->namespace; |
|
75
|
1
|
|
|
|
|
3
|
$name = $namespace . $name; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
1
|
|
|
|
|
4
|
return $self->name2tmpl->{$name}; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 get_perl5_name $template_object |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
get perl5 full path |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub get_perl5_name { |
|
87
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
88
|
1
|
|
50
|
|
|
4
|
my $tmpl = shift || return; |
|
89
|
1
|
|
|
|
|
5
|
( my $p5name = $tmpl->full_name ) =~ tr/\./_/; |
|
90
|
1
|
|
|
|
|
4
|
$p5name; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
|
94
|
|
|
|
|
|
|
__END__ |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Closure Templates Documentation L<http://code.google.com/closure/templates/docs/overview.html> |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Perl 6 implementation L<https://github.com/zag/plosurin> |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Zahatski Aliaksandr, <zag@cpan.org> |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Copyright (C) 2011 by Zahatski Aliaksandr |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
112
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
|
115
|
|
|
|
|
|
|
|