[Templates] ttree questions

Mark Anderson mda@discerning.com
Mon, 06 Oct 2003 11:11:44 -0700


>>Is there any way to get ttree to generate files with a different
>>suffix than the template?
> 
> 
> No, not that I know of.  Would be nice, though.

Ok, here is a patch that does it.

80,82d79
< my $destsuffix  = $config->suffix;
< # ensure leading "." regardless of what user supplied
< $destsuffix = ".$destsuffix" if $destsuffix && $destsuffix !~ m/^\./;
120d116
< 	  "      Suffix: $destsuffix\n",
245c241
<     my ($dest, $base, $destfile, $check, $srctime, $desttime, $mode, $uid, $gid);
---
 >     my ($dest, $base, $check, $srctime, $desttime, $mode, $uid, $gid);
247a244
 >     $dest = $destdir ? "$destdir/$file" : $file;
249,254d245
<     $destfile = $file;
<     if ($destsuffix) {
< 	if ($base =~ m/\./) {$destfile =~ s/\..*$/$destsuffix/;}
< 	else {$destfile .= $destsuffix;}
<     }
<     $dest = $destdir ? "$destdir/$destfile" : $destfile;
305c296
<         $template->process($file, $replace, $destfile)
---
 >         $template->process($file, $replace, $file)
330d320
< 	'suffix|o=s'  => { EXPAND => EXPAND_ALL, DEFAULT => '' },
455,462d444
< # The 'suffix' option indicates the file suffix to use for all generated
< # files. It may be specified with or without a leading '.', for example
< # '.html' or 'html', with the same result. The source file is used
< # unaltered if it is not specified. If it is specified, it is appended
< # to the source base name if the source has no suffix; otherwise
< # it is used instead of the source suffix.
< # suffix = .html
<
511d492
<    -o STRING (--suffix=STRING) Destination suffix (preserves source if none)
595d575
<     suffix = .html
607,611c587
< corresponding file in the B<dest> directory.
< The B<suffix> option indicates a file suffix to use in generated
< files; by default the same base file name is used in dest as is
< found in src.
< If no files are
---
 > corresponding file in the B<dest> directory.  If no files are