Josh Rosenbaum wrote:
This is what I've got outstanding from you:
* IGNORE_PLUGIN_BASE/IGNORE_STD_PLUGINS patch
http://tt2.org/pipermail/templates/2005-August/007691.html
I don't like this I'm afraid. On an aesthetic level, I think options
should be positive (DO_THIS) rather than negative (DONT_DO_THIS) wherever
possible. So it would be better to allow the user to explicitly set
STD_PLUGINS and/or PLUGIN_BASE to undef. Also, Template::Provider::Allow
and T::P::Deny provide a more general mechanism for restricting access
to resources.
But above all else there's no tests or documentation, so that one doesn't
make the grade.
Sorry for the delay in my response Andy. I've been extremely busy
lately. I've got a better patch here (attached) and am working on docs.
(Already created tests, but will attach later with docs.) Hopefully that
will work better. I also am going to get rid of the STD_PLUGINS part of
that previous patch as there was no real need for it. I must've been
smoking crack at the time, as you can simply override
Template::Plugins::STD_PLUGINS. ;) The PLUGIN_BASE deal cannot simply be
set to undef, as we still add 'Template::Plugins' no matter what. So I'm
adding a config option: 'ADD_DEFAULT_PLUGIN_BASE'. (As can be seen in
patch.) I've also included another option "PLUGINS_USE_LOWERCASE" which
just says that all keys in STD_PLUGINS and PLUGINS are lowercase, and
that we can use those plugins in a case insensitive manner. (ie: [% USE
TABLE %])
I offered to enter them into CVS myself back in the day, but never
heard back from Andy, so I'm assuming that's a rejection stamp for
CVS access. ;)
Sorry Josh, but I don't have any recollection of you asking, so it's
not a rejection stamp. However if you want to be a TT maintainer then
you do need to convince me that you would be as commited to the
documentation and tests as to the codebase.
(Repost with diffs.)
Ok Andy/guys,
Sorry for quoting so much, but I thought it was all relevant since there have
been substantial gaps of time between posts. Here is my new and improved
plugins patch with added documentation and tests. I also got rid of the
IGNORE_STD_PLUGINS config option in the previous patch, as this can be overrode
already via $Template::Plugins::STD_PLUGINS = {}; (I've made a note of that in
the documentation.) I think I've added to the documentation correctly, but feel
free to critique.
-- Josh
diff -Nru Template-Toolkit-2.14/docsrc/lib/dir/use
Template-Toolkit-2.14-changed/docsrc/lib/dir/use
--- Template-Toolkit-2.14/docsrc/lib/dir/use 2001-03-27 04:15:00.000000000
-0700
+++ Template-Toolkit-2.14-changed/docsrc/lib/dir/use 2006-01-21
00:51:48.000000000 -0700
@@ -18,6 +18,9 @@
[% USE MyPlugin %] # => Template::Plugin::MyPlugin
[% USE Foo.Bar %] # => Template::Plugin::Foo::Bar
+If you want to disable this functionality, then set the
+ADD_DEFAULT_PLUGIN_BASE config option to 0.
+
Various standard plugins are included with the Template Toolkit (see
below and L<Template::Manual::Plugins>). These can be specified in lower
case and are mapped to the appropriate name.
@@ -25,6 +28,15 @@
[% USE cgi %] # => Template::Plugin::CGI
[% USE table %] # => Template::Plugin::Table
+If you would like the standard plugins to be case-insensitive you can
+enable the PLUGINS_USE_LOWERCASE config option. This option will allow
+you to USE both standard plugins and plugins specified in the PLUGINS
+config option without worrying about case. One stipulation is that
+plugins defined in PLUGINS must have lower case hash keys.
+
+ [% USE CgI %]
+ [% USE TABLE %]
+
Any additional parameters supplied in parenthesis after the plugin
name will be also be passed to the new() constructor. A reference to
the current Template::Context object is always passed as the first
diff -Nru Template-Toolkit-2.14/docsrc/lib/option/addplugb
Template-Toolkit-2.14-changed/docsrc/lib/option/addplugb
--- Template-Toolkit-2.14/docsrc/lib/option/addplugb 1969-12-31
17:00:00.000000000 -0700
+++ Template-Toolkit-2.14-changed/docsrc/lib/option/addplugb 2006-01-26
12:37:53.000000000 -0700
@@ -0,0 +1,33 @@
+[% TAGS star %]
+[* DEFAULT
+ obj = '$template'
+ pkg = 'Template'
+-*]
+
+=item ADD_DEFAULT_PLUGIN_BASE
+
+By default, Template::Plugin:: is always checked if there is not a
+standard plugin or PLUGINS plugin defined. To stop this from happening
+you will need to set ADD_DEFAULT_PLUGIN_BASE to 0.
+
+To disable all plugins except the ones you define explicitly, you need to
+do disable a few things. First set Template::Plugins::STD_PLUGINS to an
+empty hash. Then in your config set both ADD_DEFAULT_PLUGIN_BASE and
+LOAD_PERL to a perl false value.
+
+ use Template::Plugins;
+ $Template::Plugins::STD_PLUGINS = {};
+
+ my [* obj *] = [* pkg *]->new({
+ LOAD_PERL => 0,
+ ADD_DEFAULT_PLUGIN_BASE => 0,
+ PLUGINS => {
+ cgi => 'MyOrg::Template::Plugin::CGI',
+ foo => 'MyOrg::Template::Plugin::Foo',
+ bar => 'MyOrg::Template::Plugin::Bar',
+ },
+ });
+
+After doing this, only the plugins you have defined in PLUGINS will load.
+This is useful if you are worried about the security of various plugins,
+or if you just want to limit plugin usage.
diff -Nru Template-Toolkit-2.14/docsrc/lib/option/plugins
Template-Toolkit-2.14-changed/docsrc/lib/option/plugins
--- Template-Toolkit-2.14/docsrc/lib/option/plugins 2001-03-27
04:15:01.000000000 -0700
+++ Template-Toolkit-2.14-changed/docsrc/lib/option/plugins 2006-01-21
00:46:59.000000000 -0700
@@ -31,3 +31,8 @@
If the plugin name is not defined in the PLUGINS hash then the PLUGIN_BASE
and/or LOAD_PERL options come into effect.
+If you are worried about the security of plugins or would like to restrict
+access to them, then the ADD_DEFAULT_PLUGIN_BASE, LOAD_PERL, and/or
+PLUGINS options should help you. View the ADD_DEFAULT_PLUGIN_BASE option
+for more details.
+
diff -Nru Template-Toolkit-2.14/docsrc/lib/option/pluglowr
Template-Toolkit-2.14-changed/docsrc/lib/option/pluglowr
--- Template-Toolkit-2.14/docsrc/lib/option/pluglowr 1969-12-31
17:00:00.000000000 -0700
+++ Template-Toolkit-2.14-changed/docsrc/lib/option/pluglowr 2006-01-26
12:41:28.000000000 -0700
@@ -0,0 +1,32 @@
+[% TAGS star %]
+[* DEFAULT
+ obj = '$template'
+ pkg = 'Template'
+-*]
+
+=item PLUGINS_USE_LOWERCASE
+
+If you would like the standard plugins and plugins defined in the
+PLUGINS option to be case-insensitive you can enable the
+PLUGINS_USE_LOWERCASE config option. This option will allow you to
+[% USE %] both standard plugins and plugins specified in the
+PLUGINS config option without worrying about case. One stipulation
+is that plugins defined in PLUGINS must have lower case hash keys.
+
+ my [* obj *] = [* pkg *]->new({
+ PLUGINS_USE_LOWERCASE => 1,
+ PLUGINS => {
+ # These are all fine.
+ cgi => 'MyOrg::Template::Plugin::CGI',
+ foo => 'MyOrg::Template::Plugin::Foo',
+ bar => 'MyOrg::Template::Plugin::Bar',
+
+ # This is invalid, because key is not lower case.
+ ABC => 'MyOrg::Template::Plugin::ABC',
+ },
+ });
+
+ [% USE CgI %]
+ [% USE TABLE %]
+ [% USE Bar %]
+ [% USE BAR %]
diff -Nru Template-Toolkit-2.14/docsrc/src/Manual/Config.tt2
Template-Toolkit-2.14-changed/docsrc/src/Manual/Config.tt2
--- Template-Toolkit-2.14/docsrc/src/Manual/Config.tt2 2003-04-23
08:32:28.000000000 -0600
+++ Template-Toolkit-2.14-changed/docsrc/src/Manual/Config.tt2 2006-01-21
00:42:16.000000000 -0700
@@ -149,6 +149,10 @@
[% PROCESS option/loadperl %]
+[* PROCESS option/addplugb *]
+
+[* PROCESS option/pluglowr *]
+
[% PROCESS option/filters %]
=back
diff -Nru Template-Toolkit-2.14/docsrc/src/Modules/Template/Plugins.tt2
Template-Toolkit-2.14-changed/docsrc/src/Modules/Template/Plugins.tt2
--- Template-Toolkit-2.14/docsrc/src/Modules/Template/Plugins.tt2
2002-08-08 06:22:01.000000000 -0600
+++ Template-Toolkit-2.14-changed/docsrc/src/Modules/Template/Plugins.tt2
2006-01-21 00:42:18.000000000 -0700
@@ -79,6 +79,10 @@
[* PROCESS option/loadperl *]
+[* PROCESS option/addplugb *]
+
+[* PROCESS option/pluglowr *]
+
[* PROCESS option/tolerant *]
[* PROCESS option/debug_mod/plugins *]
diff -Nru Template-Toolkit-2.14/lib/Template/Plugins.pm
Template-Toolkit-2.14-changed/lib/Template/Plugins.pm
--- Template-Toolkit-2.14/lib/Template/Plugins.pm 2004-10-04
04:27:39.000000000 -0600
+++ Template-Toolkit-2.14-changed/lib/Template/Plugins.pm 2006-01-13
00:02:43.000000000 -0700
@@ -150,12 +150,17 @@
if (ref $pbase ne 'ARRAY') {
$pbase = $pbase ? [ $pbase ] : [ ];
}
- push(@$pbase, 'Template::Plugin');
+
+ $self->{ ADD_DEFAULT_PLUGIN_BASE } = !exists($params->{
ADD_DEFAULT_PLUGIN_BASE }) || $params->{ ADD_DEFAULT_PLUGIN_BASE } || 0;
+ if ($self->{ ADD_DEFAULT_PLUGIN_BASE }){
+ push(@$pbase, 'Template::Plugin');
+ }
$self->{ PLUGIN_BASE } = $pbase;
$self->{ PLUGINS } = { %$STD_PLUGINS, %$plugins };
$self->{ TOLERANT } = $params->{ TOLERANT } || 0;
$self->{ LOAD_PERL } = $params->{ LOAD_PERL } || 0;
+ $self->{ PLUGINS_USE_LOWERCASE } = $params->{ PLUGINS_USE_LOWERCASE } || 0;
$self->{ FACTORY } = $factory || { };
$self->{ DEBUG } = ( $params->{ DEBUG } || 0 )
& Template::Constants::DEBUG_PLUGINS;
@@ -177,7 +182,7 @@
my ($self, $name, $context) = @_;
my ($factory, $module, $base, $pkg, $file, $ok, $error);
- if ($module = $self->{ PLUGINS }->{ $name }) {
+ if ($module = $self->{ PLUGINS }->{ ($self->{ PLUGINS_USE_LOWERCASE } ?
lc($name) : $name) } ) {
# plugin module name is explicitly stated in PLUGIN_NAME
$pkg = $module;
($file = $module) =~ s|::|/|g;
@@ -263,7 +268,7 @@
my $format = " %-16s => %s\n";
my $key;
- foreach $key (qw( TOLERANT LOAD_PERL )) {
+ foreach $key (qw( TOLERANT LOAD_PERL PLUGINS_USE_LOWERCASE
ADD_DEFAULT_PLUGIN_BASE)) {
$output .= sprintf($format, $key, $self->{ $key });
}
diff -Nru Template-Toolkit-2.14/t/config.t
Template-Toolkit-2.14-changed/t/config.t
--- Template-Toolkit-2.14/t/config.t 2001-03-29 16:00:53.000000000 -0700
+++ Template-Toolkit-2.14-changed/t/config.t 2006-01-13 00:09:35.000000000
-0700
@@ -22,7 +22,7 @@
use Template::Test;
use Template::Config;
-ntests(44);
+ntests(56);
$DEBUG = 0;
$Template::Config::DEBUG = 0;
@@ -92,6 +92,7 @@
|| print STDERR $factory->error(), "\n";
ok( $plugins );
+ok( $plugins->{ LOAD_PERL } == 0 );
ok( join('+', @{$plugins->{ PLUGIN_BASE }}) eq 'MyPlugins+Template::Plugin' );
$plugins = $factory->plugins({
@@ -104,6 +105,40 @@
ok( join('+', @{$plugins->{ PLUGIN_BASE }}) eq 'NewPlugins+Template::Plugin' );
+# new tests
+ok( $plugins->{ ADD_DEFAULT_PLUGIN_BASE } == 1 ); # check default
+ok( $plugins->{ PLUGINS_USE_LOWERCASE } == 0 ); # check default
+
+$plugins = $factory->plugins({
+ LOAD_PERL => 0,
+ PLUGIN_BASE => 'MyPlugins',
+ PLUGINS_USE_LOWERCASE => 1,
+ ADD_DEFAULT_PLUGIN_BASE => 0,
+}) || print STDERR $factory->error(), "\n";
+
+ok( $plugins );
+ok( join('+', @{$plugins->{ PLUGIN_BASE }}) eq 'MyPlugins' );
+ok( $plugins->{ LOAD_PERL } == 0 );
+ok( $plugins->{ ADD_DEFAULT_PLUGIN_BASE } == 0 );
+ok( $plugins->{ PLUGINS_USE_LOWERCASE } == 1 );
+
+$plugins = $factory->plugins({
+ LOAD_PERL => 1, # this must be set for a test further down
+ PLUGIN_BASE => 'NewPlugins',
+ PLUGINS_USE_LOWERCASE => 0,
+ ADD_DEFAULT_PLUGIN_BASE => 1
+}) || print STDERR $factory->error(), "\n";
+
+ok( $plugins );
+ok( $plugins->{ PLUGINS_USE_LOWERCASE } == 0 );
+ok( $plugins->{ ADD_DEFAULT_PLUGIN_BASE } == 1 );
+ok( join('+', @{$plugins->{ PLUGIN_BASE }}) eq 'NewPlugins+Template::Plugin' );
+
+
+
+
+
+
#------------------------------------------------------------------------
# filters
#------------------------------------------------------------------------
diff -Nru Template-Toolkit-2.14/t/plugins.t
Template-Toolkit-2.14-changed/t/plugins.t
--- Template-Toolkit-2.14/t/plugins.t 2002-08-08 06:00:55.000000000 -0600
+++ Template-Toolkit-2.14-changed/t/plugins.t 2006-01-20 23:09:12.000000000
-0700
@@ -53,11 +53,24 @@
DEBUG => $DEBUG ? DEBUG_PLUGINS : 0,
});
+my $tt4 = Template->new({
+ ADD_DEFAULT_PLUGIN_BASE => 0,
+ DEBUG => $DEBUG ? DEBUG_PLUGINS : 0,
+});
+
+my $tt5 = Template->new({
+ PLUGINS_USE_LOWERCASE => 1,
+ DEBUG => $DEBUG ? DEBUG_PLUGINS : 0,
+});
+
+
my $tt = [
def => Template->new(),
tt1 => $tt1,
tt2 => $tt2,
tt3 => $tt3,
+ tt4 => $tt4,
+ tt5 => $tt5,
];
test_expect(\*DATA, $tt, &callsign());
@@ -168,3 +181,63 @@
[% boz.output %]
-- expect --
This is the Baz module, value is 256
+
+
+#------------------------------------------------------------------------
+# ADD_DEFAULT_PLUGIN_BASE = 0.
+# Template::Plugins::URL no longer works since Template::Plugins is not
+# added to the default plugin base. Same with others. However, url will
+# work since it is specified as a plugin in
+# Template::Plugins::STD_PLUGINS.
+#------------------------------------------------------------------------
+
+-- test --
+-- use tt4 --
+[% TRY -%]
+[% USE URL() -%]
+[% CATCH -%]
+ERROR: [% error.info %]
+[% END %]
+-- expect --
+ERROR: URL: plugin not found
+
+-- test --
+[% USE mycgi = url('/cgi-bin/bar.pl', debug=1); %][% mycgi %]
+-- expect --
+/cgi-bin/bar.pl?debug=1
+
+
+#------------------------------------------------------------------------
+# PLUGINS_USE_LOWERCASE = 1
+# This means that the plugins we specify in the config option PLUGINS or
+# Template::Plugins::STD_PLUGINS have lowercase keys. Because of this,
+# we allow case insensitive usage in our Templates. You'll also see that
+# in tt4 (PLUGINS_USE_LOWERCASE = 0) that we cannot load 'UrL', although
+# that works fine in tt5. (PLUGINS_USE_LOWERCASE=1)
+#------------------------------------------------------------------------
+
+-- test --
+-- use tt5 --
+[% USE mycgi = url('/cgi-bin/bar.pl', debug=1); %][% mycgi %]
+-- expect --
+/cgi-bin/bar.pl?debug=1
+
+-- test --
+[% USE mycgi = URL('/cgi-bin/bar.pl', debug=1); %][% mycgi %]
+-- expect --
+/cgi-bin/bar.pl?debug=1
+
+-- test --
+[% USE mycgi = UrL('/cgi-bin/bar.pl', debug=1); %][% mycgi %]
+-- expect --
+/cgi-bin/bar.pl?debug=1
+
+-- test --
+-- use tt4 --
+[% TRY -%]
+[% USE UrL() -%]
+[% CATCH -%]
+ERROR: [% error.info %]
+[% END %]
+-- expect --
+ERROR: UrL: plugin not found
diff -Nr Template-Toolkit-2.14/docsrc/lib/dir/use
Template-Toolkit-2.14-changed/docsrc/lib/dir/use
20a21,23
> If you want to disable this functionality, then set the
> ADD_DEFAULT_PLUGIN_BASE config option to 0.
>
27a31,39
> If you would like the standard plugins to be case-insensitive you can
> enable the PLUGINS_USE_LOWERCASE config option. This option will allow
> you to USE both standard plugins and plugins specified in the PLUGINS
> config option without worrying about case. One stipulation is that
> plugins defined in PLUGINS must have lower case hash keys.
>
> [% USE CgI %]
> [% USE TABLE %]
>
diff -Nr Template-Toolkit-2.14/docsrc/lib/option/addplugb
Template-Toolkit-2.14-changed/docsrc/lib/option/addplugb
0a1,33
> [% TAGS star %]
> [* DEFAULT
> obj = '$template'
> pkg = 'Template'
> -*]
>
> =item ADD_DEFAULT_PLUGIN_BASE
>
> By default, Template::Plugin:: is always checked if there is not a
> standard plugin or PLUGINS plugin defined. To stop this from happening
> you will need to set ADD_DEFAULT_PLUGIN_BASE to 0.
>
> To disable all plugins except the ones you define explicitly, you need to
> do disable a few things. First set Template::Plugins::STD_PLUGINS to an
> empty hash. Then in your config set both ADD_DEFAULT_PLUGIN_BASE and
> LOAD_PERL to a perl false value.
>
> use Template::Plugins;
> $Template::Plugins::STD_PLUGINS = {};
>
> my [* obj *] = [* pkg *]->new({
> LOAD_PERL => 0,
> ADD_DEFAULT_PLUGIN_BASE => 0,
> PLUGINS => {
> cgi => 'MyOrg::Template::Plugin::CGI',
> foo => 'MyOrg::Template::Plugin::Foo',
> bar => 'MyOrg::Template::Plugin::Bar',
> },
> });
>
> After doing this, only the plugins you have defined in PLUGINS will load.
> This is useful if you are worried about the security of various plugins,
> or if you just want to limit plugin usage.
diff -Nr Template-Toolkit-2.14/docsrc/lib/option/plugins
Template-Toolkit-2.14-changed/docsrc/lib/option/plugins
33a34,38
> If you are worried about the security of plugins or would like to restrict
> access to them, then the ADD_DEFAULT_PLUGIN_BASE, LOAD_PERL, and/or
> PLUGINS options should help you. View the ADD_DEFAULT_PLUGIN_BASE option
> for more details.
>
diff -Nr Template-Toolkit-2.14/docsrc/lib/option/pluglowr
Template-Toolkit-2.14-changed/docsrc/lib/option/pluglowr
0a1,32
> [% TAGS star %]
> [* DEFAULT
> obj = '$template'
> pkg = 'Template'
> -*]
>
> =item PLUGINS_USE_LOWERCASE
>
> If you would like the standard plugins and plugins defined in the
> PLUGINS option to be case-insensitive you can enable the
> PLUGINS_USE_LOWERCASE config option. This option will allow you to
> [% USE %] both standard plugins and plugins specified in the
> PLUGINS config option without worrying about case. One stipulation
> is that plugins defined in PLUGINS must have lower case hash keys.
>
> my [* obj *] = [* pkg *]->new({
> PLUGINS_USE_LOWERCASE => 1,
> PLUGINS => {
> # These are all fine.
> cgi => 'MyOrg::Template::Plugin::CGI',
> foo => 'MyOrg::Template::Plugin::Foo',
> bar => 'MyOrg::Template::Plugin::Bar',
>
> # This is invalid, because key is not lower case.
> ABC => 'MyOrg::Template::Plugin::ABC',
> },
> });
>
> [% USE CgI %]
> [% USE TABLE %]
> [% USE Bar %]
> [% USE BAR %]
diff -Nr Template-Toolkit-2.14/docsrc/src/Manual/Config.tt2
Template-Toolkit-2.14-changed/docsrc/src/Manual/Config.tt2
151a152,155
> [* PROCESS option/addplugb *]
>
> [* PROCESS option/pluglowr *]
>
diff -Nr Template-Toolkit-2.14/docsrc/src/Modules/Template/Plugins.tt2
Template-Toolkit-2.14-changed/docsrc/src/Modules/Template/Plugins.tt2
81a82,85
> [* PROCESS option/addplugb *]
>
> [* PROCESS option/pluglowr *]
>
diff -Nr Template-Toolkit-2.14/lib/Template/Plugins.pm
Template-Toolkit-2.14-changed/lib/Template/Plugins.pm
153c153,157
< push(@$pbase, 'Template::Plugin');
---
>
> $self->{ ADD_DEFAULT_PLUGIN_BASE } = !exists($params->{
> ADD_DEFAULT_PLUGIN_BASE }) || $params->{ ADD_DEFAULT_PLUGIN_BASE } || 0;
> if ($self->{ ADD_DEFAULT_PLUGIN_BASE }){
> push(@$pbase, 'Template::Plugin');
> }
158a163
> $self->{ PLUGINS_USE_LOWERCASE } = $params->{ PLUGINS_USE_LOWERCASE } ||
> 0;
180c185
< if ($module = $self->{ PLUGINS }->{ $name }) {
---
> if ($module = $self->{ PLUGINS }->{ ($self->{ PLUGINS_USE_LOWERCASE } ?
> lc($name) : $name) } ) {
266c271
< foreach $key (qw( TOLERANT LOAD_PERL )) {
---
> foreach $key (qw( TOLERANT LOAD_PERL PLUGINS_USE_LOWERCASE
> ADD_DEFAULT_PLUGIN_BASE)) {
diff -Nr Template-Toolkit-2.14/t/config.t
Template-Toolkit-2.14-changed/t/config.t
25c25
< ntests(44);
---
> ntests(56);
94a95
> ok( $plugins->{ LOAD_PERL } == 0 );
106a108,141
> # new tests
> ok( $plugins->{ ADD_DEFAULT_PLUGIN_BASE } == 1 ); # check default
> ok( $plugins->{ PLUGINS_USE_LOWERCASE } == 0 ); # check default
>
> $plugins = $factory->plugins({
> LOAD_PERL => 0,
> PLUGIN_BASE => 'MyPlugins',
> PLUGINS_USE_LOWERCASE => 1,
> ADD_DEFAULT_PLUGIN_BASE => 0,
> }) || print STDERR $factory->error(), "\n";
>
> ok( $plugins );
> ok( join('+', @{$plugins->{ PLUGIN_BASE }}) eq 'MyPlugins' );
> ok( $plugins->{ LOAD_PERL } == 0 );
> ok( $plugins->{ ADD_DEFAULT_PLUGIN_BASE } == 0 );
> ok( $plugins->{ PLUGINS_USE_LOWERCASE } == 1 );
>
> $plugins = $factory->plugins({
> LOAD_PERL => 1, # this must be set for a test further down
> PLUGIN_BASE => 'NewPlugins',
> PLUGINS_USE_LOWERCASE => 0,
> ADD_DEFAULT_PLUGIN_BASE => 1
> }) || print STDERR $factory->error(), "\n";
>
> ok( $plugins );
> ok( $plugins->{ PLUGINS_USE_LOWERCASE } == 0 );
> ok( $plugins->{ ADD_DEFAULT_PLUGIN_BASE } == 1 );
> ok( join('+', @{$plugins->{ PLUGIN_BASE }}) eq 'NewPlugins+Template::Plugin'
> );
>
>
>
>
>
>
diff -Nr Template-Toolkit-2.14/t/plugins.t
Template-Toolkit-2.14-changed/t/plugins.t
55a56,66
> my $tt4 = Template->new({
> ADD_DEFAULT_PLUGIN_BASE => 0,
> DEBUG => $DEBUG ? DEBUG_PLUGINS : 0,
> });
>
> my $tt5 = Template->new({
> PLUGINS_USE_LOWERCASE => 1,
> DEBUG => $DEBUG ? DEBUG_PLUGINS : 0,
> });
>
>
60a72,73
> tt4 => $tt4,
> tt5 => $tt5,
170a184,243
>
>
> #------------------------------------------------------------------------
> # ADD_DEFAULT_PLUGIN_BASE = 0.
> # Template::Plugins::URL no longer works since Template::Plugins is not
> # added to the default plugin base. Same with others. However, url will
> # work since it is specified as a plugin in
> # Template::Plugins::STD_PLUGINS.
> #------------------------------------------------------------------------
>
> -- test --
> -- use tt4 --
> [% TRY -%]
> [% USE URL() -%]
> [% CATCH -%]
> ERROR: [% error.info %]
> [% END %]
> -- expect --
> ERROR: URL: plugin not found
>
> -- test --
> [% USE mycgi = url('/cgi-bin/bar.pl', debug=1); %][% mycgi %]
> -- expect --
> /cgi-bin/bar.pl?debug=1
>
>
> #------------------------------------------------------------------------
> # PLUGINS_USE_LOWERCASE = 1
> # This means that the plugins we specify in the config option PLUGINS or
> # Template::Plugins::STD_PLUGINS have lowercase keys. Because of this,
> # we allow case insensitive usage in our Templates. You'll also see that
> # in tt4 (PLUGINS_USE_LOWERCASE = 0) that we cannot load 'UrL', although
> # that works fine in tt5. (PLUGINS_USE_LOWERCASE=1)
> #------------------------------------------------------------------------
>
> -- test --
> -- use tt5 --
> [% USE mycgi = url('/cgi-bin/bar.pl', debug=1); %][% mycgi %]
> -- expect --
> /cgi-bin/bar.pl?debug=1
>
> -- test --
> [% USE mycgi = URL('/cgi-bin/bar.pl', debug=1); %][% mycgi %]
> -- expect --
> /cgi-bin/bar.pl?debug=1
>
> -- test --
> [% USE mycgi = UrL('/cgi-bin/bar.pl', debug=1); %][% mycgi %]
> -- expect --
> /cgi-bin/bar.pl?debug=1
>
> -- test --
> -- use tt4 --
> [% TRY -%]
> [% USE UrL() -%]
> [% CATCH -%]
> ERROR: [% error.info %]
> [% END %]
> -- expect --
> ERROR: UrL: plugin not found