Process a directory of mason 2 templates
version 0.02
use MasonX::ProcessDir; # Generate result files in the same directory as the templates # my $pd = MasonX::ProcessDir->new( dir => '/path/to/dir' ); $pd->process_dir(); # Generate result files in a separate directory # my $pd = MasonX::ProcessDir->new( source_dir => '/path/to/source/dir', dest_dir => '/path/to/dest/dir' ); $pd->process_dir();
Recursively processes a directory of Mason 2 templates, generating a set of result files in the same directory or in a parallel directory.
Every file with suffix \*(L".mc\*(R" will be processed, and the results placed in a file of the same name without the suffix. \*(L".mi\*(R", autobase and dhandler files will be used by Mason when processing the templates but will not generate files themselves.
For example, if the source directory contains
Base.mc httpd.conf.mc proxy.conf.mc etc/crontab.mc blah.mi somefile.txt
and we run
my $pd = MasonX::ProcessDir->new( source_dir => '/path/to/source/dir', dest_dir => '/path/to/dest/dir' ); $pd->process_dir();
then afterwards the destination directory will contain files
httpd.conf proxy.conf etc/crontab somefile.txt
where foo and bar are the results of processing foo.mc and bar.mc through Mason. Base.mc and blah.mi may be used during Mason processing but won't generate result files themselves.
This class is a convenience extension of Any::Template::ProcessDir.
If you want to generate the result files in the same directory as the templates, just specify dir. my $pd = MasonX::ProcessDir->new( dir => '/path/to/dir', ... );
If you want to generate the result files in a separate directory from the templates, specify source_dir and dest_dir. my $pd = MasonX::ProcessDir->new( source_dir => '/path/to/source/dir', source_dir => '/path/to/dest/dir', ... );
An optional hash of options to the Mason interpreter. For example, the default Mason data directory will be \*(L".mason\*(R" under the source directory, but you can override this: mason_options => { data_dir => '/path/to/data/dir' }
See Any::Template::ProcessDir for other options, such as
dir_create_mode file_create_mode readme_filename
Bugs and feature requests will be tracked at \s-1RT:\s0
http://rt.cpan.org/NoAuth/Bugs.html?Dist=MasonX-ProcessDir [email protected]
The latest source code can be browsed and fetched at:
http://github.com/jonswar/perl-masonx-processdir git clone git://github.com/jonswar/perl-masonx-processdir.git
Mason, Any::Template::ProcessDir
Jonathan Swartz <[email protected]>
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.