.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Any::Template::ProcessDir 3pm" .TH Any::Template::ProcessDir 3pm "2022-06-06" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Any::Template::ProcessDir \-\- Process a directory of templates .SH "VERSION" .IX Header "VERSION" version 0.08 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Any::Template::ProcessDir; \& \& # Process templates and generate result files in a single directory \& # \& my $pd = Any::Template::ProcessDir\->new( \& dir => \*(Aq/path/to/dir\*(Aq, \& process_text => sub { \& my $template = Any::Template\->new( Backend => \*(Aq...\*(Aq, String => $_[0] ); \& $template\->process({ ... }); \& } \& ); \& $pd\->process_dir(); \& \& # Process templates and generate result files to a separate directory \& # \& my $pd = Any::Template::ProcessDir\->new( \& source_dir => \*(Aq/path/to/source/dir\*(Aq, \& dest_dir => \*(Aq/path/to/dest/dir\*(Aq, \& process_file => sub { \& my $file = $_[0]; \& # do something with $file, return content \& } \& ); \& $pd\->process_dir(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Recursively processes a directory of templates, generating a set of result files in the same directory or in a parallel directory. Each file in the source directory may be template-processed, copied, or ignored depending on its pathname. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .SS "Specifying directory/directories" .IX Subsection "Specifying directory/directories" .IP "\(bu" 4 If you want to generate the result files in the \fBsame\fR directory as the templates, just specify \fIdir\fR. .Sp .Vb 4 \& my $pd = Any::Template::ProcessDir\->new( \& dir => \*(Aq/path/to/dir\*(Aq, \& ... \& ); .Ve .IP "\(bu" 4 If you want to generate the result files in a \fBseparate\fR directory from the templates, specify \fIsource_dir\fR and \fIdest_dir\fR. .Sp .Vb 5 \& my $pd = Any::Template::ProcessDir\->new( \& source_dir => \*(Aq/path/to/source/dir\*(Aq, \& dest_dir => \*(Aq/path/to/dest/dir\*(Aq, \& ... \& ); .Ve .SS "Specifying how to process templates" .IX Subsection "Specifying how to process templates" .IP "process_file" 4 .IX Item "process_file" A code reference that takes the full template filename and the \&\f(CW\*(C`Any::Template::ProcessDir\*(C'\fR object as arguments, and returns the result string. This can use Any::Template or another method altogether. By default it calls \*(L"process_text\*(R" on the contents of the file. .IP "process_text" 4 .IX Item "process_text" A code reference that takes the template text and the \&\f(CW\*(C`Any::Template::ProcessDir\*(C'\fR object as arguments, and returns the result string. This can use Any::Template or another method altogether. .SS "Optional parameters" .IX Subsection "Optional parameters" .IP "dir_create_mode" 4 .IX Item "dir_create_mode" Permissions mode to use when creating destination directories. Defaults to 0775. No effect if you are using a single directory. .IP "file_create_mode" 4 .IX Item "file_create_mode" Permissions mode to use when creating destination files. Defaults to 0444 (read-only), so that destination files are not accidentally edited. .IP "ignore_files" 4 .IX Item "ignore_files" Coderef which takes a full pathname and returns true if the file should be ignored. By default, all files will be considered. .IP "readme_filename" 4 .IX Item "readme_filename" Name of a \s-1README\s0 file to generate in the destination directory \- defaults to \&\*(L"\s-1README\*(R".\s0 No file will be generated if you pass undef or if you are using a single directory. .IP "template_file_suffix" 4 .IX Item "template_file_suffix" Suffix of template files in source directory. Defaults to \*(L".src\*(R". This will be removed from the destination file name. .Sp Any file in the source directory that does not have this suffix (or \&\*(L"ignore_file_suffix\*(R") will simply be copied to the destination. .SH "METHODS" .IX Header "METHODS" .IP "process_dir" 4 .IX Item "process_dir" Process the directory. If using multiple directories, the destination directory will be removed completely and recreated, to eliminate any old files from previous processing. .SH "SEE ALSO" .IX Header "SEE ALSO" Any::Template .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2011 by Jonathan Swartz. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.