line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Templer::Plugin::Dollar - A simple shell-like syntax for template variables. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=cut |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 DESCRIPTION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This class implements a layout template filter plugin for C which |
11
|
|
|
|
|
|
|
allows template variables to be included using a dollar sign followed by an |
12
|
|
|
|
|
|
|
open brace, the variable name and a closing brace. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This allows template such as this to be used |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=for example begin |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
${title escape="html"} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=for example end |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Everything between the variable name and the closing brace is used B in |
30
|
|
|
|
|
|
|
the transformation. The third line of the example is for instance transformed |
31
|
|
|
|
|
|
|
as |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=for example begin |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=for example end |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 LICENSE |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
44
|
|
|
|
|
|
|
under the terms of either: |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
a) the GNU General Public License as published by the Free Software |
47
|
|
|
|
|
|
|
Foundation; either version 2, or (at your option) any later version, |
48
|
|
|
|
|
|
|
or |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
b) the Perl "Artistic License". |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 AUTHOR |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Bruno Beaufils |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Copyright (C) 2015 Bruno Beaufils . |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This library is free software. You can modify and or distribute it under |
65
|
|
|
|
|
|
|
the same terms as Perl itself. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 METHODS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
11
|
|
|
11
|
|
5299
|
use strict; |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
263
|
|
75
|
11
|
|
|
11
|
|
45
|
use warnings; |
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
1908
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
package Templer::Plugin::Dollar; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 new |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Constructor. No arguments are supported/expected. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub new |
88
|
|
|
|
|
|
|
{ |
89
|
6
|
|
|
6
|
1
|
10
|
my ( $proto, %supplied ) = (@_); |
90
|
6
|
|
33
|
|
|
19
|
my $class = ref($proto) || $proto; |
91
|
|
|
|
|
|
|
|
92
|
6
|
|
|
|
|
8
|
my $self = {}; |
93
|
6
|
|
|
|
|
9
|
bless( $self, $class ); |
94
|
6
|
|
|
|
|
11
|
return $self; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 available |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This plugin is always available. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub available |
105
|
|
|
|
|
|
|
{ |
106
|
1
|
|
|
1
|
1
|
5
|
return 1; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 filter |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Filter the given template. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub filter |
117
|
|
|
|
|
|
|
{ |
118
|
3
|
|
|
3
|
1
|
5
|
my ( $self, $str ) = (@_); |
119
|
|
|
|
|
|
|
|
120
|
3
|
|
|
|
|
45
|
$str =~ s/\$\{([^:\s}]+)([^}]*)\}//g; |
121
|
|
|
|
|
|
|
|
122
|
3
|
|
|
|
|
11
|
return $str; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Templer::Plugin::Factory->new() |
126
|
|
|
|
|
|
|
->register_filter( "dollar", "Templer::Plugin::Dollar" ); |