| 1 |
NAME |
| 2 |
MasonX::ProcessDir - Process a directory of Mason 2 templates |
| 3 |
|
| 4 |
VERSION |
| 5 |
version 0.02 |
| 6 |
|
| 7 |
SYNOPSIS |
| 8 |
use MasonX::ProcessDir; |
| 9 |
|
| 10 |
# Generate result files in the same directory as the templates |
| 11 |
# |
| 12 |
my $pd = MasonX::ProcessDir->new( |
| 13 |
dir => '/path/to/dir' |
| 14 |
); |
| 15 |
$pd->process_dir(); |
| 16 |
|
| 17 |
# Generate result files in a separate directory |
| 18 |
# |
| 19 |
my $pd = MasonX::ProcessDir->new( |
| 20 |
source_dir => '/path/to/source/dir', |
| 21 |
dest_dir => '/path/to/dest/dir' |
| 22 |
); |
| 23 |
$pd->process_dir(); |
| 24 |
|
| 25 |
DESCRIPTION |
| 26 |
Recursively processes a directory of Mason 2 templates, generating a set |
| 27 |
of result files in the same directory or in a parallel directory. |
| 28 |
|
| 29 |
Every file with suffix ".mc" will be processed, and the results placed |
| 30 |
in a file of the same name without the suffix. ".mi", autobase and |
| 31 |
dhandler files will be used by Mason when processing the templates but |
| 32 |
will not generate files themselves. |
| 33 |
|
| 34 |
For example, if the source directory contains |
| 35 |
|
| 36 |
Base.mc |
| 37 |
httpd.conf.mc |
| 38 |
proxy.conf.mc |
| 39 |
etc/crontab.mc |
| 40 |
blah.mi |
| 41 |
somefile.txt |
| 42 |
|
| 43 |
and we run |
| 44 |
|
| 45 |
my $pd = MasonX::ProcessDir->new( |
| 46 |
source_dir => '/path/to/source/dir', |
| 47 |
dest_dir => '/path/to/dest/dir' |
| 48 |
); |
| 49 |
$pd->process_dir(); |
| 50 |
|
| 51 |
then afterwards the destination directory will contain files |
| 52 |
|
| 53 |
httpd.conf |
| 54 |
proxy.conf |
| 55 |
etc/crontab |
| 56 |
somefile.txt |
| 57 |
|
| 58 |
where *foo* and *bar* are the results of processing *foo.mc* and |
| 59 |
*bar.mc* through Mason. *Base.mc* and *blah.mi* may be used during Mason |
| 60 |
processing but won't generate result files themselves. |
| 61 |
|
| 62 |
This class is a convenience extension of Any::Template::ProcessDir. |
| 63 |
|
| 64 |
CONSTRUCTOR |
| 65 |
Specifying directory/directories |
| 66 |
* If you want to generate the result files in the same directory as |
| 67 |
the templates, just specify *dir*. |
| 68 |
|
| 69 |
my $pd = MasonX::ProcessDir->new( |
| 70 |
dir => '/path/to/dir', |
| 71 |
... |
| 72 |
); |
| 73 |
|
| 74 |
* If you want to generate the result files in a separate directory |
| 75 |
from the templates, specify *source_dir* and *dest_dir*. |
| 76 |
|
| 77 |
my $pd = MasonX::ProcessDir->new( |
| 78 |
source_dir => '/path/to/source/dir', |
| 79 |
source_dir => '/path/to/dest/dir', |
| 80 |
... |
| 81 |
); |
| 82 |
|
| 83 |
Mason options |
| 84 |
mason_options |
| 85 |
An optional hash of options to the Mason interpreter. For example, |
| 86 |
the default Mason data directory will be ".mason" under the source |
| 87 |
directory, but you can override this: |
| 88 |
|
| 89 |
mason_options => { data_dir => '/path/to/data/dir' } |
| 90 |
|
| 91 |
Options inherited from Any::Template::ProcessDir |
| 92 |
See Any::Template::ProcessDir for other options, such as |
| 93 |
|
| 94 |
dir_create_mode |
| 95 |
file_create_mode |
| 96 |
readme_filename |
| 97 |
|
| 98 |
SUPPORT AND DOCUMENTATION |
| 99 |
Bugs and feature requests will be tracked at RT: |
| 100 |
|
| 101 |
http://rt.cpan.org/NoAuth/Bugs.html?Dist=MasonX-ProcessDir |
| 102 |
[email protected] |
| 103 |
|
| 104 |
The latest source code can be browsed and fetched at: |
| 105 |
|
| 106 |
http://github.com/jonswar/perl-masonx-processdir |
| 107 |
git clone git://github.com/jonswar/perl-masonx-processdir.git |
| 108 |
|
| 109 |
SEE ALSO |
| 110 |
Mason, Any::Template::ProcessDir |
| 111 |
|
| 112 |
AUTHOR |
| 113 |
Jonathan Swartz <[email protected]> |
| 114 |
|
| 115 |
COPYRIGHT AND LICENSE |
| 116 |
This software is copyright (c) 2011 by Jonathan Swartz. |
| 117 |
|
| 118 |
This is free software; you can redistribute it and/or modify it under |
| 119 |
the same terms as the Perl 5 programming language system itself. |
| 120 |
|