MasonX...essDir(3pm)

πŸ“¦
version 0.02 Β· 2 versions
  • 0.02 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.02 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… MasonX::ProcessDir β€” or, as your shell knows it, MasonX...essDir(3pm)

okay bestie, gather round, because this one is genuinely a little gem and i need you to know about it. it's a Perl module, it's documented in the user-contributed Perl docs section, and it does exactly one thing extremely well: it takes a whole directory of Mason 2 templates and cooks them into result files. no cap. πŸŽ€


✨ NAME ✨

MasonX::ProcessDir β€” Process a directory of Mason 2 templates πŸ¦‹


🌸 VERSION 🌸

version 0.02 πŸ’œ


πŸŽ€ SYNOPSIS πŸŽ€

here's the whole vibe in code form, literally copy-paste ready:

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

πŸ’– DESCRIPTION πŸ’–

so what it does is: it goes recursively through a directory of Mason 2 templates and spits out a whole set of result files β€” either right there in the same directory, or in a parallel directory of your choosing. main character energy for build scripts, honestly.

every single file with the suffix .mc gets processed, and its result lands in a file with the same name minus that suffix. meanwhile .mi files, autobase files and dhandler files? those get used by Mason while it's doing its thing, but they do not generate files themselves. they're the supporting cast, not the leads. πŸ™ˆ

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. 🫢

and like β€” this class is a convenience extension of Any::Template::ProcessDir. it's the glow-up, not a whole new species. ✨


🧚 CONSTRUCTOR 🧚

πŸ“ Specifying directory/directories

  • if you want the result files to land in the same directory as the templates, you literally just specify dir. that's it. that's the whole move. πŸ’…
my $pd = MasonX::ProcessDir->new(
    dir => '/path/to/dir',
    ...
);
  • if you want the result files in a separate directory from the templates, you specify source_dir and dest_dir.
my $pd = MasonX::ProcessDir->new(
    source_dir => '/path/to/source/dir',
    source_dir => '/path/to/dest/dir',
    ...
);

🌈 Mason options

  • mason_options β€” an optional hash of options passed to the Mason interpreter. for example, the default Mason data directory will be .mason under the source directory, but you can override that, no problem:
mason_options => { data_dir => '/path/to/data/dir' }

πŸ‘‘ Options inherited from Any::Template::ProcessDir

go check Any::Template::ProcessDir for the other options, such as

dir_create_mode
file_create_mode
readme_filename

⭐ SUPPORT AND DOCUMENTATION ⭐

bugs and feature requests will be tracked at RT β€” yes, RT, the classic. bring your receipts:

http://rt.cpan.org/NoAuth/Bugs.html?Dist=MasonX-ProcessDir
bug-masonx-processdir@rt.cpan.org

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

πŸ¦‹ SEE ALSO πŸ¦‹

Mason, Any::Template::ProcessDir

iykyk. 🌸


πŸ’œ AUTHOR πŸ’œ

Jonathan Swartz <swartz@pobox.com>


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.


and that's the whole page bestie, periodt. πŸ’–

perl v5.34.0 Β· 2022-06-15 Β· and this manual page's very own name, MasonX...essDir(3pm) β€” she's iconic, she's truncated, she slays. 🫢✨

πŸ“¦ where this page comes from