On Mon, Sep 05, 2005 at 07:41:55AM -0700, Bill Moseley wrote:
> On Mon, Sep 05, 2005 at 02:27:36PM +0100, Stephen Quinney wrote:
> > I have two variables and I want to remove the contents of one from the
> > other. The situation in this case is a directory name (dir) and a
> > filename (name) which is an absolute path. I want to display the
> > filename part only with the directories removed.
>
I can do something like:
[% SET dir = "/a/b/c/d/e/"
name = "/a/b/c/d/e/d.txt" %]
[% name | remove(dir) %]
and it gives me what I want but I wanted to pass in the '^' and put
\Q, \E around the contents of dir to protect from any unwanted regexp
metacharacters that might be in the directory name.
> Does the path exist? If so, there's the File plugin:
>
> $ perl -MTemplate -le '$t=q![% USE File( "/usr/bin/perl"); File.name %]!;
> Template->new->process(\$t)'
> perl
>
> If you don't mind the stat.
No, the file doesn't exist on the webserver.
>
> Hum. I thought there was a File::Basename plugin.
I can't see one but it would certainly be a very useful addition.
Stephen
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates