Showing
7 changed files
with
357 additions
and
0 deletions
This diff is collapsed. Click to expand it.
1 | + | ||
2 | +package Text::Template::Preprocess; | ||
3 | +use Text::Template; | ||
4 | +@ISA = qw(Text::Template); | ||
5 | +$Text::Template::Preprocess::VERSION = 1.46; | ||
6 | + | ||
7 | +sub fill_in { | ||
8 | + my $self = shift; | ||
9 | + my (%args) = @_; | ||
10 | + my $pp = $args{PREPROCESSOR} || $self->{PREPROCESSOR} ; | ||
11 | + if ($pp) { | ||
12 | + local $_ = $self->source(); | ||
13 | +# print "# fill_in: before <$_>\n"; | ||
14 | + &$pp; | ||
15 | +# print "# fill_in: after <$_>\n"; | ||
16 | + $self->set_source_data($_); | ||
17 | + } | ||
18 | + $self->SUPER::fill_in(@_); | ||
19 | +} | ||
20 | + | ||
21 | +sub preprocessor { | ||
22 | + my ($self, $pp) = @_; | ||
23 | + my $old_pp = $self->{PREPROCESSOR}; | ||
24 | + $self->{PREPROCESSOR} = $pp if @_ > 1; # OK to pass $pp=undef | ||
25 | + $old_pp; | ||
26 | +} | ||
27 | + | ||
28 | +1; | ||
29 | + | ||
30 | + | ||
31 | +=head1 NAME | ||
32 | + | ||
33 | +Text::Template::Preprocess - Expand template text with embedded Perl | ||
34 | + | ||
35 | +=head1 VERSION | ||
36 | + | ||
37 | +This file documents C<Text::Template::Preprocess> version B<1.46> | ||
38 | + | ||
39 | +=head1 SYNOPSIS | ||
40 | + | ||
41 | + use Text::Template::Preprocess; | ||
42 | + | ||
43 | + my $t = Text::Template::Preprocess->new(...); # identical to Text::Template | ||
44 | + | ||
45 | + # Fill in template, but preprocess each code fragment with pp(). | ||
46 | + my $result = $t->fill_in(..., PREPROCESSOR => \&pp); | ||
47 | + | ||
48 | + my $old_pp = $t->preprocessor(\&new_pp); | ||
49 | + | ||
50 | +=head1 DESCRIPTION | ||
51 | + | ||
52 | +C<Text::Template::Preprocess> provides a new C<PREPROCESSOR> option to | ||
53 | +C<fill_in>. If the C<PREPROCESSOR> option is supplied, it must be a | ||
54 | +reference to a preprocessor subroutine. When filling out a template, | ||
55 | +C<Text::Template::Preprocessor> will use this subroutine to preprocess | ||
56 | +the program fragment prior to evaluating the code. | ||
57 | + | ||
58 | +The preprocessor subroutine will be called repeatedly, once for each | ||
59 | +program fragment. The program fragment will be in C<$_>. The | ||
60 | +subroutine should modify the contents of C<$_> and return. | ||
61 | +C<Text::Template::Preprocess> will then execute contents of C<$_> and | ||
62 | +insert the result into the appropriate part of the template. | ||
63 | + | ||
64 | +C<Text::Template::Preprocess> objects also support a utility method, | ||
65 | +C<preprocessor()>, which sets a new preprocessor for the object. This | ||
66 | +preprocessor is used for all subsequent calls to C<fill_in> except | ||
67 | +where overridden by an explicit C<PREPROCESSOR> option. | ||
68 | +C<preprocessor()> returns the previous default preprocessor function, | ||
69 | +or undefined if there wasn't one. When invoked with no arguments, | ||
70 | +C<preprocessor()> returns the object's current default preprocessor | ||
71 | +function without changing it. | ||
72 | + | ||
73 | +In all other respects, C<Text::Template::Preprocess> is identical to | ||
74 | +C<Text::Template>. | ||
75 | + | ||
76 | +=head1 WHY? | ||
77 | + | ||
78 | +One possible purpose: If your files contain a lot of JavaScript, like | ||
79 | +this: | ||
80 | + | ||
81 | + | ||
82 | + Plain text here... | ||
83 | + { perl code } | ||
84 | + <script language=JavaScript> | ||
85 | + if (br== "n3") { | ||
86 | + // etc. | ||
87 | + } | ||
88 | + </script> | ||
89 | + { more perl code } | ||
90 | + More plain text... | ||
91 | + | ||
92 | +You don't want C<Text::Template> to confuse the curly braces in the | ||
93 | +JavaScript program with executable Perl code. One strategy: | ||
94 | + | ||
95 | + sub quote_scripts { | ||
96 | + s(<script(.*?)</script>)(q{$1})gsi; | ||
97 | + } | ||
98 | + | ||
99 | +Then use C<PREPROCESSOR =E<gt> \"e_scripts>. This will transform | ||
100 | + | ||
101 | + | ||
102 | + | ||
103 | +=head1 SEE ALSO | ||
104 | + | ||
105 | +L<Text::Template> | ||
106 | + | ||
107 | +=head1 AUTHOR | ||
108 | + | ||
109 | + | ||
110 | +Mark Jason Dominus, Plover Systems | ||
111 | + | ||
112 | +Please send questions and other remarks about this software to | ||
113 | +C<mjd-perl-template+@plover.com> | ||
114 | + | ||
115 | +You can join a very low-volume (E<lt>10 messages per year) mailing | ||
116 | +list for announcements about this package. Send an empty note to | ||
117 | +C<mjd-perl-template-request@plover.com> to join. | ||
118 | + | ||
119 | +For updates, visit C<http://www.plover.com/~mjd/perl/Template/>. | ||
120 | + | ||
121 | +=head1 LICENSE | ||
122 | + | ||
123 | + Text::Template::Preprocess version 1.46 | ||
124 | + Copyright 2013 Mark Jason Dominus | ||
125 | + | ||
126 | + This program is free software; you can redistribute it and/or | ||
127 | + modify it under the terms of the GNU General Public License as | ||
128 | + published by the Free Software Foundation; either version 2 of the | ||
129 | + License, or (at your option) any later version. You may also can | ||
130 | + redistribute it and/or modify it under the terms of the Perl | ||
131 | + Artistic License. | ||
132 | + | ||
133 | + This program is distributed in the hope that it will be useful, | ||
134 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
135 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
136 | + GNU General Public License for more details. | ||
137 | + | ||
138 | + You should have received copies of the GNU General Public License | ||
139 | + along with this program; if not, write to the Free Software | ||
140 | + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
141 | + | ||
142 | + | ||
143 | +=cut | ||
144 | + |
src/optimized/test/certs/subinterCA-ss.pem
0 → 100644
1 | +-----BEGIN CERTIFICATE----- | ||
2 | +MIIDhzCCAm+gAwIBAgIJAJTed6XmFiu/MA0GCSqGSIb3DQEBCwUAMFoxCzAJBgNV | ||
3 | +BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX | ||
4 | +aWRnaXRzIFB0eSBMdGQxEzARBgNVBAMMCnN1YmludGVyQ0EwHhcNMTUwNzAyMTMy | ||
5 | +MTU4WhcNMzUwNzAyMTMyMTU4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KoBvpSpSJndZN6UcH7Z1yn41Y6AnO4u492jiRAjQpP9+Nf/x1eg== | ||
21 | +-----END CERTIFICATE----- |
src/optimized/test/certs/subinterCA.key
0 → 100644
1 | +-----BEGIN RSA PRIVATE KEY----- | ||
2 | +MIIEpQIBAAKCAQEA/zQjvhbU7RWDsRaEkVUBZWR/PqZ49GoE9p3OyRN4pkt1c1yb | ||
3 | +2ARVkYZP5e9gHb04wPVz2+FYy+2mNkl+uAZbcK5w5fWO3WJIEn57he4MkWu3ew1n | ||
4 | +JeSv3na8gyOoCheG64kWVbA2YL92mR7QoSCo4SP7RmykLrwj6TlDxqgH6DxKSD/C | ||
5 | +pdCHE3DKAzAiri3GVc90OJAszYHlje4/maVIOayGROVET3xa5cbtRJl8IBgmqhMy | ||
6 | +wtz4hhY/XZTvdEn290aL857Hk7JjogA7mLKi07yKzknMxHV+k6JX7xJEttkcNQRF | ||
7 | +HONWZG1T4mRY1Drh6VbJGb+0GNIldNLQqigkfwIDAQABAoIBAQDg14MWGu+F4gqg | ||
8 | +nwI1OPt95UjmXaz7Sd0NmoNxTKJjgN/9v33emBL7n6YNIxU/nlK+ToLBGo0tPjfO | ||
9 | +ZHoskA1H/aiiMfKowcpV4PHbUZvpE0oYM/rIu+7mxR3ZPDT0jz3jjmgLHrEKFCXd | ||
10 | +SfTtwOSJVzYvGdCdDE1nUXiRMcGlrJYxPf+0k3sGK7G90rYJkgffz92yuJote/s5 | ||
11 | +P5nsK1h30yjKaWEzvf3ABladplykFN3GkICRGaCq0Nj5YWiG7qX9H9smYrioG0VH | ||
12 | +VqgIbV2sHnmUYZaOTmC0RnwDWSZR25xOHVbugZ7rGnf4NdoM2S/oTI/SAXcDsaDX | ||
13 | +lDpiEEuBAoGBAP/TISpeDRtUWzfVQxH+wbMdSbABjawf5sT7op7IsWsurY7u+KVh | ||
14 | +ubhaSdeR7YbTyVUqbAc4mg9TIZxDe6+/I2S8LibQAa8wnv5aR1iPj/tZJOKrtu+Z | ||
15 | +uHUyXMDR+8pIjQS0N+ukFp0tw9nicPNUt23JpqDFMvpASF+kUlnHOWAvAoGBAP9g | ||
16 | +5rDid235QnnAhNJGkxE1ZwICPSo66AD/kF8XsMnAVasR0EPJCQ1+Zmh7wsXGq6Im | ||
17 | +S65F4m0tsw4jeD67D1o5yuAnk/LLcdOdHW1w7iHuIhYKuWf1fqsOIqJLy7gdzwj4 | ||
18 | +hImECoE40cqlLTge7xByxeHJwKF9ssXcwHFBIJyxAoGBAI5SeyUC5e/KYmURdBrS | ||
19 | +zBhFtvUAKD0WEmCMTdBgfrPOaCgYsqPvVk9Fi8cuHCLiOCP1UdxClRLpgM1ajbkc | ||
20 | +cShduJ9HIWjBd/KxbvfKBqQi1+5y8Xci4gfxWMC9EYNcEXgIewPRafNPvqG85HG7 | ||
21 | +M8EUamsOymmG0bzDwjzIJRdpAoGAOUoVtmy3ehZG0WVc5ocqitu+BfdWnViln0O1 | ||
22 | +sX9xC3F4Rm4ymGJLA5ntg1bwNMoCytdodun6h5+O4YcXfIseQJFib7KxP/Bf0qcW | ||
23 | +aOzCnx36y5MQUMAD8H+1SU9TnjQhs9N8eBUE/kQu3BT99e8KllgJCEPoUNIP/s8s | ||
24 | +5LtFg6ECgYEAgLwJoJ3hBwr0LmUi3kpFYdbZ+tAKIvKQH3xYMnQulOqtlXJFy0bu | ||
25 | +ZcIAwsigRUqdCC2JuyAUw52HCtVVlpQjNs4BnUzaKooLOCm3w3i6X27mnHE0200S | ||
26 | +zqC0rcB0xNz/IltGc7IP+T8UK5xX38uhJ/vUW75OvAjqheJSBwR9h5c= | ||
27 | +-----END RSA PRIVATE KEY----- |
src/optimized/test/certs/subinterCA.pem
0 → 100644
1 | +-----BEGIN CERTIFICATE----- | ||
2 | +MIIDhDCCAmygAwIBAgIJAJkv2OGshkmUMA0GCSqGSIb3DQEBCwUAMFcxCzAJBgNV | ||
3 | +BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5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ozc2SZSMRUq9ryn4Wq | ||
19 | +YrjRl8NwioGb1LfjEJ0wJi2ngL3IgaN94qmDn10OJs8hlsufwP1n+Bca3fsl0m5U | ||
20 | +gUMG+CXxbF0kdCKZ9kQb1MJE4vOk6zfyBGQndmQnxHjt5botI/xpXg== | ||
21 | +-----END CERTIFICATE----- |
This diff is collapsed. Click to expand it.
1 | + | ||
2 | +package Text::Template::Preprocess; | ||
3 | +use Text::Template; | ||
4 | +@ISA = qw(Text::Template); | ||
5 | +$Text::Template::Preprocess::VERSION = 1.46; | ||
6 | + | ||
7 | +sub fill_in { | ||
8 | + my $self = shift; | ||
9 | + my (%args) = @_; | ||
10 | + my $pp = $args{PREPROCESSOR} || $self->{PREPROCESSOR} ; | ||
11 | + if ($pp) { | ||
12 | + local $_ = $self->source(); | ||
13 | +# print "# fill_in: before <$_>\n"; | ||
14 | + &$pp; | ||
15 | +# print "# fill_in: after <$_>\n"; | ||
16 | + $self->set_source_data($_); | ||
17 | + } | ||
18 | + $self->SUPER::fill_in(@_); | ||
19 | +} | ||
20 | + | ||
21 | +sub preprocessor { | ||
22 | + my ($self, $pp) = @_; | ||
23 | + my $old_pp = $self->{PREPROCESSOR}; | ||
24 | + $self->{PREPROCESSOR} = $pp if @_ > 1; # OK to pass $pp=undef | ||
25 | + $old_pp; | ||
26 | +} | ||
27 | + | ||
28 | +1; | ||
29 | + | ||
30 | + | ||
31 | +=head1 NAME | ||
32 | + | ||
33 | +Text::Template::Preprocess - Expand template text with embedded Perl | ||
34 | + | ||
35 | +=head1 VERSION | ||
36 | + | ||
37 | +This file documents C<Text::Template::Preprocess> version B<1.46> | ||
38 | + | ||
39 | +=head1 SYNOPSIS | ||
40 | + | ||
41 | + use Text::Template::Preprocess; | ||
42 | + | ||
43 | + my $t = Text::Template::Preprocess->new(...); # identical to Text::Template | ||
44 | + | ||
45 | + # Fill in template, but preprocess each code fragment with pp(). | ||
46 | + my $result = $t->fill_in(..., PREPROCESSOR => \&pp); | ||
47 | + | ||
48 | + my $old_pp = $t->preprocessor(\&new_pp); | ||
49 | + | ||
50 | +=head1 DESCRIPTION | ||
51 | + | ||
52 | +C<Text::Template::Preprocess> provides a new C<PREPROCESSOR> option to | ||
53 | +C<fill_in>. If the C<PREPROCESSOR> option is supplied, it must be a | ||
54 | +reference to a preprocessor subroutine. When filling out a template, | ||
55 | +C<Text::Template::Preprocessor> will use this subroutine to preprocess | ||
56 | +the program fragment prior to evaluating the code. | ||
57 | + | ||
58 | +The preprocessor subroutine will be called repeatedly, once for each | ||
59 | +program fragment. The program fragment will be in C<$_>. The | ||
60 | +subroutine should modify the contents of C<$_> and return. | ||
61 | +C<Text::Template::Preprocess> will then execute contents of C<$_> and | ||
62 | +insert the result into the appropriate part of the template. | ||
63 | + | ||
64 | +C<Text::Template::Preprocess> objects also support a utility method, | ||
65 | +C<preprocessor()>, which sets a new preprocessor for the object. This | ||
66 | +preprocessor is used for all subsequent calls to C<fill_in> except | ||
67 | +where overridden by an explicit C<PREPROCESSOR> option. | ||
68 | +C<preprocessor()> returns the previous default preprocessor function, | ||
69 | +or undefined if there wasn't one. When invoked with no arguments, | ||
70 | +C<preprocessor()> returns the object's current default preprocessor | ||
71 | +function without changing it. | ||
72 | + | ||
73 | +In all other respects, C<Text::Template::Preprocess> is identical to | ||
74 | +C<Text::Template>. | ||
75 | + | ||
76 | +=head1 WHY? | ||
77 | + | ||
78 | +One possible purpose: If your files contain a lot of JavaScript, like | ||
79 | +this: | ||
80 | + | ||
81 | + | ||
82 | + Plain text here... | ||
83 | + { perl code } | ||
84 | + <script language=JavaScript> | ||
85 | + if (br== "n3") { | ||
86 | + // etc. | ||
87 | + } | ||
88 | + </script> | ||
89 | + { more perl code } | ||
90 | + More plain text... | ||
91 | + | ||
92 | +You don't want C<Text::Template> to confuse the curly braces in the | ||
93 | +JavaScript program with executable Perl code. One strategy: | ||
94 | + | ||
95 | + sub quote_scripts { | ||
96 | + s(<script(.*?)</script>)(q{$1})gsi; | ||
97 | + } | ||
98 | + | ||
99 | +Then use C<PREPROCESSOR =E<gt> \"e_scripts>. This will transform | ||
100 | + | ||
101 | + | ||
102 | + | ||
103 | +=head1 SEE ALSO | ||
104 | + | ||
105 | +L<Text::Template> | ||
106 | + | ||
107 | +=head1 AUTHOR | ||
108 | + | ||
109 | + | ||
110 | +Mark Jason Dominus, Plover Systems | ||
111 | + | ||
112 | +Please send questions and other remarks about this software to | ||
113 | +C<mjd-perl-template+@plover.com> | ||
114 | + | ||
115 | +You can join a very low-volume (E<lt>10 messages per year) mailing | ||
116 | +list for announcements about this package. Send an empty note to | ||
117 | +C<mjd-perl-template-request@plover.com> to join. | ||
118 | + | ||
119 | +For updates, visit C<http://www.plover.com/~mjd/perl/Template/>. | ||
120 | + | ||
121 | +=head1 LICENSE | ||
122 | + | ||
123 | + Text::Template::Preprocess version 1.46 | ||
124 | + Copyright 2013 Mark Jason Dominus | ||
125 | + | ||
126 | + This program is free software; you can redistribute it and/or | ||
127 | + modify it under the terms of the GNU General Public License as | ||
128 | + published by the Free Software Foundation; either version 2 of the | ||
129 | + License, or (at your option) any later version. You may also can | ||
130 | + redistribute it and/or modify it under the terms of the Perl | ||
131 | + Artistic License. | ||
132 | + | ||
133 | + This program is distributed in the hope that it will be useful, | ||
134 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
135 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
136 | + GNU General Public License for more details. | ||
137 | + | ||
138 | + You should have received copies of the GNU General Public License | ||
139 | + along with this program; if not, write to the Free Software | ||
140 | + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
141 | + | ||
142 | + | ||
143 | +=cut | ||
144 | + |
-
Please register or login to post a comment