> This is not the case.  INCLUDE_PATH is static and global.

You can change INCLUDE_PATH as often as you like.  Admittedly, the docs
don't make this very clear, but it is an Officially Approved Technique.  I
change it once per request, but as I suggested in my last mail you could
change it in your Context::visit() method.

Here's an example (untested) that will make TT do a depth-first search from
the current working directory:

use File::Spec;
sub visit {
    my ($self, $doc) = @_;
    my $epath = $doc->{_epath};
    my @inc_path;

    # this is from Darren Chamberlain's mail, with File::Spec to suport
Win32
    for (File::Spec->splitdir($epath)) {
        push @inc_path, File::Spec->canonpath("$inc_path[-1]/$_");
    }
    @inc_path = reverse @inc_path;

    # set new INCLUDE_PATH
    # the [0] will have to change if you use multiple Providers
    $self->load_templates->[0]->include_path(\@inc_path)

    $self->SUPER::visit($self, $doc);
}

- Perrin



Reply via email to