Dist::Zilla::Plugin::Templates - Treat source files as templates
Version v0.6.5, released on 2018-03-22 20:35 UTC.
Dist-Zilla-Plugin-Templates (or just Templates for brevity) is a Dist-Zilla plugin allowing developers to insert Perl code fragments into arbitrary source text files, which become templates. When Dist::Zilla builds the distribution each code fragment is evaluated and replaced with result of evaluation.
Dist-Zilla-Plugin-Templates
Templates
Dist-Zilla
Dist::Zilla
This is Dist::Zilla::Plugin::Templates module documentation. Read this if you are going to hack or extend Dist-Zilla-Plugin-Templates.
Dist::Zilla::Plugin::Templates
If you want to treat source files as templates, read the manual. General topics like getting source, building, installing, bug reporting and some others are covered in the README.
Implementation of the plugin is trivial. It just consumes few roles which do all the work: FileFinderUser provides a list of files, TextTemplater process them.
FileFinderUser
TextTemplater
This is the primary method of the plugin. It is called by Dist::Zilla during build. The method iterates through the files provided by $self->found_files (a method defined in FileFinderUser role) and process each file with $self->fill_in_file (a method defined in TextTemplater role). That's all, folks.
$self->found_files
$self->fill_in_file
This method implements same-name template function. Normally, templates should call the function, not method:
{{ include( 'filename' ); }}
However, if something wrong with the function, file inclusion can be made through the method call:
{{ $plugin->include( 'filename' ); }}
Van de Bugger <van.de.bugger@gmail.com>
Copyright (C) 2015, 2016, 2018 Van de Bugger
License GPLv3+: The GNU General Public License version 3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
To install Dist::Zilla::Plugin::Templates, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dist::Zilla::Plugin::Templates
CPAN shell
perl -MCPAN -e shell install Dist::Zilla::Plugin::Templates
For more information on module installation, please visit the detailed CPAN module installation guide.