* Andy Wardley <[EMAIL PROTECTED]> [2002-07-08 10:45]:
> Anyway, having given it some thought, I now believe the simplest and 
> best approach is to allow INCLUDE_PATH to be passed a subroutine, or 
> an object which implements a method for generating a list of paths.
> This is in addition to regular path strings, of course.

This sounds good, and is consistent with the behavior of other parts of
TT.

>     @paths = @{ $self->{ INCLUDE_PATH } };
> 
>     while (@paths) {
>         $dir = shift @paths || next;
> 
>         if (ref $dir eq 'CODE') {
>             push(@paths, &$dir());
>             next;
>         }
>         elsif (UNIVERSAL::can($dir, 'paths')) {
>            push(@paths, $dir->paths());
>            next;
>         }
>         else {
>             $path = "$dir/$name";
>         }
> 
>         ...
>     }

I'm worried about things like this:

    my $path_generator;
    $path_generator = sub {
        return $path_generator;
    };

    my $tt = Template->new({
        INCLUDE_PATH => [ $path_generator ];
    });

No one would do something this obvious, of course, but the possibility
of unintentionally doing this is there.

(darren)

-- 
Blore's Razor:
    Given a choice between two theories, take the one
    which is funnier.


Reply via email to