line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
###############################################################################
|
2
|
|
|
|
|
|
|
#Variable.pm
|
3
|
|
|
|
|
|
|
#Last Change: 2009-01-19
|
4
|
|
|
|
|
|
|
#Copyright (c) 2009 Marc-Seabstian "Maluku" Lucksch
|
5
|
|
|
|
|
|
|
#Version 0.8
|
6
|
|
|
|
|
|
|
####################
|
7
|
|
|
|
|
|
|
#This file is part of the Dotiac::DTL project.
|
8
|
|
|
|
|
|
|
#http://search.cpan.org/perldoc?Dotiac::DTL
|
9
|
|
|
|
|
|
|
#
|
10
|
|
|
|
|
|
|
#Variable.pm is published under the terms of the MIT license, which basically
|
11
|
|
|
|
|
|
|
#means "Do with it whatever you want". For more information, see the
|
12
|
|
|
|
|
|
|
#license.txt file that should be enclosed with libsofu distributions. A copy of
|
13
|
|
|
|
|
|
|
#the license is (at the time of writing) also available at
|
14
|
|
|
|
|
|
|
#http://www.opensource.org/licenses/mit-license.php .
|
15
|
|
|
|
|
|
|
###############################################################################
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package Dotiac::DTL::Variable;
|
18
|
11
|
|
|
11
|
|
62
|
use strict;
|
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
1603
|
|
19
|
11
|
|
|
11
|
|
260
|
use warnings;
|
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
1232
|
|
20
|
11
|
|
|
11
|
|
67
|
use base qw/Dotiac::DTL::Tag/;
|
|
11
|
|
|
|
|
1442
|
|
|
11
|
|
|
|
|
16585
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = 0.8;
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new {
|
25
|
267
|
|
|
267
|
1
|
466
|
my $class=shift;
|
26
|
267
|
|
|
|
|
1176
|
my $self={p=>shift()};
|
27
|
267
|
|
|
|
|
620
|
bless $self,$class;
|
28
|
267
|
|
|
|
|
399
|
my $name=shift();
|
29
|
267
|
|
|
|
|
967
|
$name=~s/^\s+//;
|
30
|
267
|
|
|
|
|
900
|
$name=~s/\s+$//;
|
31
|
|
|
|
|
|
|
# $name=~s/"((?>(?:(?>[^"\\]+)|\\.)*))"/Dotiac::DTL::escap($1)/eg;
|
32
|
|
|
|
|
|
|
# $name=~s/'((?>(?:(?>[^'\\]+)|\\.)*))'/Dotiac::DTL::escap($1)/eg;
|
33
|
267
|
|
|
|
|
817
|
my @name=Dotiac::DTL::get_variables($name);
|
34
|
267
|
|
|
|
|
782
|
my @data= split/\|/,$name[0];
|
35
|
267
|
|
|
|
|
644
|
$self->{name}=shift(@data);
|
36
|
267
|
|
|
|
|
688
|
$self->{filters}=[@data];
|
37
|
267
|
|
|
|
|
511
|
$self->{n}=shift;
|
38
|
267
|
|
|
|
|
1678
|
return $self;
|
39
|
|
|
|
|
|
|
}
|
40
|
|
|
|
|
|
|
sub print {
|
41
|
427
|
|
|
427
|
1
|
657
|
my $self=shift;
|
42
|
427
|
|
|
|
|
479
|
my $param=shift;
|
43
|
427
|
|
|
|
|
459
|
my $escape=shift;
|
44
|
427
|
|
|
|
|
489
|
my $e=$escape;
|
45
|
427
|
50
|
33
|
|
|
1222
|
$e=0 if $self->{name} eq "block.super" and $param->{"block.super"};
|
46
|
427
|
|
|
|
|
1359
|
print $self->{p},Dotiac::DTL::apply_filters(Dotiac::DTL::devar_var($self->{name},$param,$e,@_),$param,$e,@{$self->{filters}})->string();
|
|
427
|
|
|
|
|
1377
|
|
47
|
427
|
|
|
|
|
2101
|
$self->{n}->print($param,$escape,@_);
|
48
|
427
|
|
|
|
|
1190
|
return;
|
49
|
|
|
|
|
|
|
}
|
50
|
|
|
|
|
|
|
sub string {
|
51
|
473
|
|
|
473
|
1
|
902
|
my $self=shift;
|
52
|
473
|
|
|
|
|
606
|
my $param=shift;
|
53
|
473
|
|
|
|
|
503
|
my $escape=shift;
|
54
|
473
|
|
|
|
|
516
|
my $e=$escape;
|
55
|
473
|
50
|
33
|
|
|
1410
|
$e=0 if $self->{name} eq "block.super" and $param->{"block.super"};
|
56
|
473
|
|
|
|
|
1592
|
return $self->{p}.Dotiac::DTL::apply_filters(Dotiac::DTL::devar_var($self->{name},$param,$e,@_),$param,$e,@{$self->{filters}})->string().$self->{n}->string($param,$escape,@_);
|
|
473
|
|
|
|
|
1676
|
|
57
|
|
|
|
|
|
|
}
|
58
|
|
|
|
|
|
|
sub perlinit {
|
59
|
277
|
|
|
277
|
1
|
377
|
my $self=shift;
|
60
|
277
|
|
|
|
|
347
|
my $fh=shift;
|
61
|
277
|
|
|
|
|
320
|
my $id=shift;
|
62
|
|
|
|
|
|
|
#use Carp;
|
63
|
|
|
|
|
|
|
#confess unless $id;
|
64
|
277
|
|
|
|
|
986
|
return $self->{n}->perlinit($fh,$id+1,@_);
|
65
|
|
|
|
|
|
|
}
|
66
|
|
|
|
|
|
|
sub perl {
|
67
|
277
|
|
|
277
|
1
|
425
|
my $self=shift;
|
68
|
277
|
|
|
|
|
379
|
my $fh=shift;
|
69
|
277
|
|
|
|
|
338
|
my $id=shift;
|
70
|
277
|
|
|
|
|
417
|
print $fh "my ";
|
71
|
277
|
|
|
|
|
1507
|
print $fh (Data::Dumper->Dump([$self->{p}],["\$text$id"]));
|
72
|
277
|
|
|
|
|
10674
|
print $fh "my ";
|
73
|
277
|
|
|
|
|
736
|
my $x=$self->{name};
|
74
|
|
|
|
|
|
|
|
75
|
277
|
100
|
|
|
|
1196
|
$x=Dotiac::DTL::descap(substr($x,1,-1)) if substr($x,0,1) eq "`";
|
76
|
277
|
|
|
|
|
1347
|
print $fh (Data::Dumper->Dump([$x],["\$var$id"]));
|
77
|
277
|
100
|
|
|
|
10254
|
if (@{$self->{filters}}) {
|
|
277
|
|
|
|
|
983
|
|
78
|
182
|
|
|
|
|
331
|
print $fh "my ";
|
79
|
182
|
|
|
|
|
944
|
print $fh (Data::Dumper->Dump([$self->{filters}],["\$filters$id"]));
|
80
|
|
|
|
|
|
|
}
|
81
|
277
|
|
|
|
|
8758
|
return $self->{n}->perl($fh,$id+1,@_);
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
}
|
84
|
|
|
|
|
|
|
sub perlprint {
|
85
|
274
|
|
|
274
|
1
|
543
|
my $self=shift;
|
86
|
274
|
|
|
|
|
346
|
my $fh=shift;
|
87
|
274
|
|
|
|
|
342
|
my $id=shift;
|
88
|
274
|
|
|
|
|
344
|
my $level=shift;
|
89
|
274
|
|
|
|
|
712
|
print $fh "\t" x $level,"print \$text$id, ";
|
90
|
274
|
|
|
|
|
383
|
my $e="\$escape";
|
91
|
274
|
50
|
|
|
|
732
|
if ($self->{name} eq "block.super") {
|
92
|
0
|
|
|
|
|
0
|
print $fh "\t" x $level,"my \$e$id=\$escape;\n";
|
93
|
0
|
|
|
|
|
0
|
print $fh "\t" x $level,"\$e$id=0 if \$vars->{\"block.super\"};\n";
|
94
|
0
|
|
|
|
|
0
|
$e="\$e$id";
|
95
|
|
|
|
|
|
|
}
|
96
|
|
|
|
|
|
|
#print $fh "\t" x $level,"print ";
|
97
|
274
|
100
|
|
|
|
314
|
print $fh "Dotiac::DTL::apply_filters(" if @{$self->{filters}};
|
|
274
|
|
|
|
|
974
|
|
98
|
274
|
100
|
|
|
|
727
|
if (substr($self->{name},0,1) eq "`") {
|
99
|
119
|
|
|
|
|
249
|
print $fh "Dotiac::DTL::Value->safe(\$var$id)";
|
100
|
|
|
|
|
|
|
}
|
101
|
|
|
|
|
|
|
else {
|
102
|
155
|
100
|
|
|
|
192
|
print $fh "Dotiac::DTL::devar_var(\$var$id,\$vars,$e,\@_)" if @{$self->{filters}};
|
|
155
|
|
|
|
|
502
|
|
103
|
155
|
100
|
|
|
|
250
|
print $fh "Dotiac::DTL::devar_raw(\$var$id,\$vars,$e,\@_)" unless @{$self->{filters}};
|
|
155
|
|
|
|
|
523
|
|
104
|
|
|
|
|
|
|
}
|
105
|
274
|
100
|
|
|
|
356
|
print $fh ",\$vars,$e,\@{\$filters$id})" if @{$self->{filters}};
|
|
274
|
|
|
|
|
11201
|
|
106
|
274
|
|
|
|
|
578
|
print $fh "->string();\n";
|
107
|
274
|
|
|
|
|
1085
|
return $self->{n}->perlprint($fh,$id+1,$level,@_);
|
108
|
|
|
|
|
|
|
}
|
109
|
|
|
|
|
|
|
sub perlstring {
|
110
|
280
|
|
|
280
|
1
|
433
|
my $self=shift;
|
111
|
280
|
|
|
|
|
325
|
my $fh=shift;
|
112
|
280
|
|
|
|
|
326
|
my $id=shift;
|
113
|
280
|
|
|
|
|
327
|
my $level=shift;
|
114
|
280
|
|
|
|
|
358
|
my $e="\$escape";
|
115
|
280
|
50
|
|
|
|
758
|
if ($self->{name} eq "block.super") {
|
116
|
0
|
|
|
|
|
0
|
print $fh "\t" x $level,"my \$e$id=\$escape;\n";
|
117
|
0
|
|
|
|
|
0
|
print $fh "\t" x $level,"\$e$id=0 if \$vars->{\"block.super\"};\n";
|
118
|
0
|
|
|
|
|
0
|
$e="\$e$id";
|
119
|
|
|
|
|
|
|
}
|
120
|
280
|
|
|
|
|
774
|
print $fh "\t" x $level,"\$r.=\$text$id.";
|
121
|
|
|
|
|
|
|
#print $fh "\t" x $level,"\$r.=";
|
122
|
280
|
100
|
|
|
|
326
|
print $fh "Dotiac::DTL::apply_filters(" if @{$self->{filters}};
|
|
280
|
|
|
|
|
789
|
|
123
|
280
|
100
|
|
|
|
782
|
if (substr($self->{name},0,1) eq "`") {
|
124
|
119
|
|
|
|
|
252
|
print $fh "Dotiac::DTL::Value->safe(\$var$id)";
|
125
|
|
|
|
|
|
|
}
|
126
|
|
|
|
|
|
|
else {
|
127
|
161
|
100
|
|
|
|
185
|
print $fh "Dotiac::DTL::devar_var(\$var$id,\$vars,$e,\@_)" if @{$self->{filters}};
|
|
161
|
|
|
|
|
541
|
|
128
|
161
|
100
|
|
|
|
232
|
print $fh "Dotiac::DTL::devar_raw(\$var$id,\$vars,$e,\@_)" unless @{$self->{filters}};
|
|
161
|
|
|
|
|
554
|
|
129
|
|
|
|
|
|
|
}
|
130
|
280
|
100
|
|
|
|
337
|
print $fh ",\$vars,$e,\@{\$filters$id})" if @{$self->{filters}};
|
|
280
|
|
|
|
|
869
|
|
131
|
280
|
|
|
|
|
449
|
print $fh "->string();\n";
|
132
|
280
|
|
|
|
|
1183
|
return $self->{n}->perlstring($fh,$id+1,$level,@_);
|
133
|
|
|
|
|
|
|
}
|
134
|
|
|
|
|
|
|
sub perlcount {
|
135
|
0
|
|
|
0
|
1
|
0
|
my $self=shift;
|
136
|
0
|
|
|
|
|
0
|
my $id=shift;
|
137
|
0
|
|
|
|
|
0
|
return $self->{n}->perlcount($id+1);
|
138
|
|
|
|
|
|
|
}
|
139
|
|
|
|
|
|
|
sub eval {
|
140
|
0
|
|
|
0
|
1
|
0
|
return;
|
141
|
|
|
|
|
|
|
}
|
142
|
|
|
|
|
|
|
sub perleval {
|
143
|
277
|
|
|
277
|
1
|
360
|
my $self=shift;
|
144
|
277
|
|
|
|
|
308
|
my $fh=shift;
|
145
|
277
|
|
|
|
|
302
|
my $id=shift;
|
146
|
277
|
|
|
|
|
293
|
my $level=shift;
|
147
|
277
|
|
|
|
|
953
|
return $self->{n}->perleval($fh,$id+1,$level,@_);
|
148
|
|
|
|
|
|
|
}
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
1;
|
151
|
|
|
|
|
|
|
__END__
|