The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Dist::Zilla::Plugin::MungeFile - Modify files in the build, with templates and arbitrary extra variables

VERSION

version 0.009

SYNOPSIS

In your dist.ini:

    [MungeFile]
    file = lib/My/Module.pm
    house = maison

And during the build, lib/My/Module.pm:

    my @stuff = qw(
        {{
            expensive_build_time_sub($house)
        }}
    );
    my ${{ $house }} = 'my castle';

Is transformed to:

    my @stuff = qw(
        ...list generated from "maison"
    );
    my $maison = 'my castle';

DESCRIPTION

This is a FileMunger plugin for Dist::Zilla that passes a file(s) through a Text::Template.

The Dist::Zilla object (as $dist) and this plugin (as $plugin) are also made available to the template, for extracting other information about the build.

Additionally, any extra keys and values you pass to the plugin are passed along in variables named for each key.

OPTIONS

finder

This is the name of a FileFinder for finding files to modify.

Other pre-defined finders are listed in "default_finders" in Dist::Zilla::Role::FileFinderUser. You can define your own with the [FileFinder::ByName] plugin.

There is no default.

file

Indicates the filename in the dist to be operated upon; this file can exist on disk, or have been generated by some other plugin. Can be included more than once.

At least one of the finder or file options is required.

arbitrary option

All other keys/values provided will be passed to the template as is.

METHODS

munge_file

    $plugin->munge_file($file, { key => val, ... });

In addition to the standard $file argument, a hashref is accepted which contains additional data to be passed through to fill_in_string.

BACKGROUND

This module has been refactored out of Dist:Zilla::Plugin::MungeFile::WithDataSection and Dist::Zilla::Plugin::MungeFile::WithConfigFile to make it more visible as a general template-runner file-munging plugin.

SUPPORT

Bugs may be submitted through the RT bug tracker (or bug-Dist-Zilla-Plugin-MungeFile@rt.cpan.org). I am also usually active on irc, as 'ether' at irc.perl.org.

SEE ALSO

AUTHOR

Karen Etheridge <ether@cpan.org>

COPYRIGHT AND LICENCE

This software is copyright (c) 2013 by Karen Etheridge.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.