Any::Template::ProcessDir -- Process a directory of templates
use Any::Template::ProcessDir; my $pd = Any::Template::ProcessDir->new( source_dir => '/path/to/source/dir', dest_dir => '/path/to/dest/dir', process_text => sub { my $template = Any::Template->new( Backend => '...', String => $_[0] ); $template->process({ ... }); } ); $pd->process_dir();
Recursively processes a directory of templates, generating a parallel directory of result files. Each file in the source directory may be template-processed, copied, or ignored depending on its pathname.
Required parameters:
Directory containing the template files.
Directory where you want to generate result files.
A code reference that takes a single argument, the template text, and returns the result string. This can use Any::Template or another method altogether.
Optional parameters:
Permissions mode to use when creating destination directories. Defaults to 0775.
Permissions mode to use when creating destination files. Defaults to 0444 (read-only), so that destination files are not accidentally edited.
Coderef which takes a full pathname and returns true if the file should be ignored. By default, all files will be considered.
Name of a README file to generate in the destination directory - defaults to "README".
Suffix of template files in source directory. Defaults to ".src". This will be removed from the destination file name.
Any file in the source directory that does not have this suffix (or "ignore_file_suffix") will simply be copied to the destination.
Process the directory. The destination directory will be removed completely and recreated, to eliminate any old files from previous processing.
Jonathan Swartz
Any::Template
Copyright (C) 2009 Jonathan Swartz.
Any::Template::ProcessDir is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantibility and fitness for a particular purpose.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Any::Template::ProcessDir, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Any::Template::ProcessDir
CPAN shell
perl -MCPAN -e shell install Any::Template::ProcessDir
For more information on module installation, please visit the detailed CPAN module installation guide.