On Sat, Jan 29, 2005 at 10:22:35PM +0100, Johan Vromans wrote:
> Yes, it is possible to construct the 'real' current directory using
> the template source directory and the path name of the current
> template, but this is cumbersome.

I had a similar question a while back.  (My quick look showed that
Template::Provider::_load() didn't set a "path" template variable
(only name, relative to include path).

So, I stored the include path in my template vars and then looked up
the file in my Plugin.   I suspect there's an easier way to get at the
INCLUDE_PATH, but...

So, something like:

    use File::Basename;
    use File::Spec;
    my $template = $context->stash->get( 'template.name' );
    my $include  = $context->stash->get( 'my.include_path' );

    my $dir;
    for ( @$include ) {
        my $path = File::Spec->catfile( $_, $template );
        if ( -f $path ) {
            $dir = dirname( $path );
            last;
        }
    }




-- 
Bill Moseley
[EMAIL PROTECTED]


_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to