Debian Codegraph @

README

raw
1 NAME
2 Any::Template::ProcessDir -- Process a directory of templates
3
4 VERSION
5 version 0.08
6
7 SYNOPSIS
8 use Any::Template::ProcessDir;
9
10 # Process templates and generate result files in a single directory
11 #
12 my $pd = Any::Template::ProcessDir->new(
13 dir => '/path/to/dir',
14 process_text => sub {
15 my $template = Any::Template->new( Backend => '...', String => $_[0] );
16 $template->process({ ... });
17 }
18 );
19 $pd->process_dir();
20
21 # Process templates and generate result files to a separate directory
22 #
23 my $pd = Any::Template::ProcessDir->new(
24 source_dir => '/path/to/source/dir',
25 dest_dir => '/path/to/dest/dir',
26 process_file => sub {
27 my $file = $_[0];
28 # do something with $file, return content
29 }
30 );
31 $pd->process_dir();
32
33 DESCRIPTION
34 Recursively processes a directory of templates, generating a set of
35 result files in the same directory or in a parallel directory. Each file
36 in the source directory may be template-processed, copied, or ignored
37 depending on its pathname.
38
39 CONSTRUCTOR
40 Specifying directory/directories
41 * If you want to generate the result files in the same directory as
42 the templates, just specify *dir*.
43
44 my $pd = Any::Template::ProcessDir->new(
45 dir => '/path/to/dir',
46 ...
47 );
48
49 * If you want to generate the result files in a separate directory
50 from the templates, specify *source_dir* and *dest_dir*.
51
52 my $pd = Any::Template::ProcessDir->new(
53 source_dir => '/path/to/source/dir',
54 dest_dir => '/path/to/dest/dir',
55 ...
56 );
57
58 Specifying how to process templates
59 process_file
60 A code reference that takes the full template filename and the
61 `Any::Template::ProcessDir' object as arguments, and returns the
62 result string. This can use Any::Template or another method
63 altogether. By default it calls process_text on the contents of the
64 file.
65
66 process_text
67 A code reference that takes the template text and the
68 `Any::Template::ProcessDir' object as arguments, and returns the
69 result string. This can use Any::Template or another method
70 altogether.
71
72 Optional parameters
73 dir_create_mode
74 Permissions mode to use when creating destination directories.
75 Defaults to 0775. No effect if you are using a single directory.
76
77 file_create_mode
78 Permissions mode to use when creating destination files. Defaults to
79 0444 (read-only), so that destination files are not accidentally
80 edited.
81
82 ignore_files
83 Coderef which takes a full pathname and returns true if the file
84 should be ignored. By default, all files will be considered.
85
86 readme_filename
87 Name of a README file to generate in the destination directory -
88 defaults to "README". No file will be generated if you pass undef or
89 if you are using a single directory.
90
91 template_file_suffix
92 Suffix of template files in source directory. Defaults to ".src".
93 This will be removed from the destination file name.
94
95 Any file in the source directory that does not have this suffix (or
96 ignore_file_suffix) will simply be copied to the destination.
97
98 METHODS
99 process_dir
100 Process the directory. If using multiple directories, the
101 destination directory will be removed completely and recreated, to
102 eliminate any old files from previous processing.
103
104 SEE ALSO
105 Any::Template
106
107 COPYRIGHT AND LICENSE
108 This software is copyright (c) 2011 by Jonathan Swartz.
109
110 This is free software; you can redistribute it and/or modify it under
111 the same terms as the Perl 5 programming language system itself.
112