line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Clevery::Util; |
2
|
14
|
|
|
14
|
|
79
|
use strict; |
|
14
|
|
|
|
|
22
|
|
|
14
|
|
|
|
|
3300
|
|
3
|
14
|
|
|
14
|
|
70
|
use warnings; |
|
14
|
|
|
|
|
1240
|
|
|
14
|
|
|
|
|
3407
|
|
4
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
70
|
use parent qw(Exporter); |
|
14
|
|
|
|
|
1431
|
|
|
14
|
|
|
|
|
1357
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
8
|
|
|
|
|
|
|
safe_join |
9
|
|
|
|
|
|
|
safe_cat |
10
|
|
|
|
|
|
|
make_tag |
11
|
|
|
|
|
|
|
true |
12
|
|
|
|
|
|
|
false |
13
|
|
|
|
|
|
|
ceil floor |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
14
|
|
|
|
|
5810
|
use Text::Xslate::Util qw( |
17
|
|
|
|
|
|
|
p |
18
|
|
|
|
|
|
|
mark_raw html_escape |
19
|
14
|
|
|
14
|
|
2496
|
); |
|
14
|
|
|
|
|
24
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub true() { 1 } |
23
|
|
|
|
|
|
|
sub false() { 0 } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub make_tag { |
26
|
490
|
|
|
490
|
0
|
4052
|
my $name = shift; |
27
|
490
|
|
|
|
|
547
|
my $content = shift; |
28
|
490
|
|
|
|
|
552
|
my $attrs = ''; |
29
|
490
|
|
|
|
|
1749
|
while(my($name, $value) = splice @_, 0, 2) { |
30
|
555
|
100
|
|
|
|
1018
|
if(defined $value) { |
31
|
549
|
|
|
|
|
5813
|
$attrs .= sprintf q{ %s="%s"}, html_escape($name), html_escape($value); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
490
|
100
|
|
|
|
858
|
if(defined $content) { |
35
|
454
|
|
|
|
|
4086
|
return mark_raw(sprintf q{<%1$s%2$s>%3$s%1$s>}, $name, $attrs, html_escape($content)); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
36
|
|
|
|
|
285
|
return mark_raw(sprintf q{<%1$s%2$s />}, $name, $attrs); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub safe_join { |
43
|
69
|
|
|
69
|
0
|
110
|
my $sep = shift; |
44
|
489
|
|
|
|
|
3121
|
return mark_raw join html_escape($sep)->as_string, |
45
|
69
|
|
|
|
|
342
|
map { html_escape($_)->as_string } @_; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub safe_cat { |
49
|
254
|
|
|
|
|
1431
|
return mark_raw join '', |
50
|
108
|
|
|
108
|
0
|
261
|
map { html_escape($_)->as_string } @_; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub floor { |
54
|
4
|
|
|
4
|
0
|
6
|
my($n) = @_; |
55
|
4
|
50
|
|
|
|
24
|
return int(int($n) > $n ? $n - 1 : $n); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub ceil { |
59
|
7
|
|
|
7
|
0
|
1469
|
my($n) = @_; |
60
|
7
|
100
|
|
|
|
45
|
return int(int($n) < $n ? $n + 1 : $n); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |