The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Any::Template::ProcessDir -- Process a directory of templates

SYNOPSIS

    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();
    

DESCRIPTION

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.

CONSTRUCTOR

Required parameters:

source_dir

Directory containing the template files.

dest_dir

Directory where you want to generate result files.

process_text

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:

dir_create_mode

Permissions mode to use when creating destination directories. Defaults to 0775.

file_create_mode

Permissions mode to use when creating destination files. Defaults to 0444 (read-only), so that destination files are not accidentally edited.

ignore_files

Coderef which takes a full pathname and returns true if the file should be ignored. By default, all files will be considered.

readme_filename

Name of a README file to generate in the destination directory - defaults to "README".

template_file_suffix

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.

METHODS

process_dir

Process the directory. The destination directory will be removed completely and recreated, to eliminate any old files from previous processing.

AUTHOR

Jonathan Swartz

SEE ALSO

Any::Template

COPYRIGHT & LICENSE

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.