line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nephia::MetaTemplate; |
2
|
3
|
|
|
3
|
|
27524
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
98
|
|
3
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
75
|
|
4
|
3
|
|
|
3
|
|
2074
|
use utf8; |
|
3
|
|
|
|
|
22
|
|
|
3
|
|
|
|
|
17
|
|
5
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
6
|
3
|
|
|
|
|
27
|
new => 0, |
7
|
|
|
|
|
|
|
rw => [qw[tag argument arrow oneliner replace_table]], |
8
|
3
|
|
|
3
|
|
3146
|
); |
|
3
|
|
|
|
|
4070
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
5
|
|
|
5
|
0
|
4895
|
my ($class, %opts) = @_; |
12
|
5
|
|
100
|
|
|
38
|
$opts{tag} ||= '= ... ?>'; |
13
|
5
|
|
100
|
|
|
29
|
$opts{arrow} ||= '}->{'; |
14
|
5
|
|
100
|
|
|
30
|
$opts{argument} ||= '$arg->{...}'; |
15
|
5
|
|
100
|
|
|
46
|
$opts{replace_table} ||= [qr|^| => '? my $arg = shift;'."\n"]; |
16
|
5
|
|
|
|
|
39
|
bless +{%opts}, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub process { |
20
|
2
|
|
|
2
|
0
|
13
|
my ($self, $instr) = @_; |
21
|
2
|
|
|
|
|
4
|
my $str = $instr; |
22
|
2
|
|
|
|
|
32
|
for my $tag ( ($str =~ m|(\[\= .*? \=\])|g) ) { |
23
|
6
|
|
|
|
|
29
|
my ($content) = $tag =~ m|\[\= (.*?) \=\]|; |
24
|
6
|
|
|
|
|
8
|
my $raw_content = $content; |
25
|
6
|
|
|
|
|
14
|
my $arrow = $self->{arrow}; |
26
|
6
|
|
|
|
|
15
|
$content =~ s|\.|$arrow|g; |
27
|
6
|
|
|
|
|
12
|
my $argument = $self->{argument}; |
28
|
6
|
|
|
|
|
15
|
$argument =~ s|\.\.\.|$content|; |
29
|
6
|
|
|
|
|
10
|
my $replace = $self->{tag}; |
30
|
6
|
|
|
|
|
18
|
$replace =~ s|\.\.\.|$argument|; |
31
|
6
|
|
|
|
|
101
|
$str =~ s|\[\= $raw_content \=\]|$replace|; |
32
|
|
|
|
|
|
|
} |
33
|
2
|
|
66
|
|
|
14
|
while ( $self->{replace_table}[0] && $self->{replace_table}[1] ) { |
34
|
1
|
|
|
|
|
2
|
my $search = shift(@{$self->{replace_table}}); |
|
1
|
|
|
|
|
4
|
|
35
|
1
|
|
|
|
|
2
|
my $replace = shift(@{$self->{replace_table}}); |
|
1
|
|
|
|
|
3
|
|
36
|
1
|
|
|
|
|
13
|
$str =~ s|$search|$replace|; |
37
|
|
|
|
|
|
|
} |
38
|
2
|
|
|
|
|
12
|
return $str; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Nephia::MetaTemplate - Meta Template Processor for Nephia::Setup flavors |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
A template in your flavor. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
[= title =] |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Access to value: [= title =] |
58
|
|
|
|
|
|
|
Access to nested value: [= author.name =] |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|