| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Templer::Plugin::Strict - A XML-like strict syntax for templates tags. |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=cut |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This class implements a layout template filter plugin for C<templer> which |
|
11
|
|
|
|
|
|
|
allows empty-element template tags to be written as in XML. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This allows the following syntax |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=over |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=item C<<TMPL_VAR NAME="PARAMETER_NAME"/>> |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=item C<<TMPL_INCLUDE NAME="filename.tmpl"/>> |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=item C<<TMPL_ELSE/>> |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=back |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 LICENSE |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
|
30
|
|
|
|
|
|
|
under the terms of either: |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
a) the GNU General Public License as published by the Free Software |
|
33
|
|
|
|
|
|
|
Foundation; either version 2, or (at your option) any later version, |
|
34
|
|
|
|
|
|
|
or |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
b) the Perl "Artistic License". |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 AUTHOR |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Bruno Beaufils <bruno@boulgour.com> |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Copyright (C) 2015 Bruno Beaufils <bruno@boulgour.com>. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This library is free software. You can modify and or distribute it under |
|
51
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
11
|
|
|
11
|
|
4782
|
use strict; |
|
|
11
|
|
|
|
|
14
|
|
|
|
11
|
|
|
|
|
266
|
|
|
61
|
11
|
|
|
11
|
|
32
|
use warnings; |
|
|
11
|
|
|
|
|
12
|
|
|
|
11
|
|
|
|
|
1875
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
package Templer::Plugin::Strict; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 new |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Constructor. No arguments are supported/expected. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub new |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
3
|
|
|
3
|
1
|
6
|
my ( $proto, %supplied ) = (@_); |
|
76
|
3
|
|
33
|
|
|
18
|
my $class = ref($proto) || $proto; |
|
77
|
|
|
|
|
|
|
|
|
78
|
3
|
|
|
|
|
4
|
my $self = {}; |
|
79
|
3
|
|
|
|
|
4
|
bless( $self, $class ); |
|
80
|
3
|
|
|
|
|
8
|
return $self; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 available |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This plugin is always available. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub available |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
1
|
|
|
1
|
1
|
4
|
return 1; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 filter |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Filter the given template. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub filter |
|
103
|
|
|
|
|
|
|
{ |
|
104
|
3
|
|
|
3
|
1
|
4
|
my ( $self, $str ) = (@_); |
|
105
|
|
|
|
|
|
|
|
|
106
|
3
|
|
|
|
|
30
|
$str =~ s{\<tmpl_var([^>/]*)/\>}{<tmpl_var$1>}ig; |
|
107
|
3
|
|
|
|
|
15
|
$str =~ s{\<tmpl_include([^>/]*)/\>}{<tmpl_include$1>}ig; |
|
108
|
3
|
|
|
|
|
11
|
$str =~ s{\<tmpl_else/\>}{<tmpl_else>}ig; |
|
109
|
|
|
|
|
|
|
|
|
110
|
3
|
|
|
|
|
9
|
return $str; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Templer::Plugin::Factory->new() |
|
114
|
|
|
|
|
|
|
->register_filter( "strict", "Templer::Plugin::Strict" ); |
|
115
|
|
|
|
|
|
|
|