NAME

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

VERSION

version 0.03

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

# or

my $pd = Any::Template::ProcessDir->new(
    source_dir   => '/path/to/source/dir',
    dest_dir     => '/path/to/dest/dir',
    process_text => sub {
        my $file = $_[0];
        # do something with $file, return content
    }
);
$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.

Plus one of these:

process_file

A code reference that takes a single argument, the full template filename, and returns the result string. This can use Any::Template or another method altogether.

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.

SEE ALSO

Any::Template

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Jonathan Swartz.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.