Graham Ollis


Dist::Zilla::Plugin::Template::Tiny - process template files in your dist using Template::Tiny


version 0.04




This plugin processes TT template files included in your distribution using Template::Tiny (a subset of Template Toolkit). It provides a single variable dzil which is an instance of Dist::Zilla which can be queried for things like the version or name of the distribution.



Specifies a FileFinder for the TT files that you want processed. If not specified all TT files with the .tt extension will be processed.

 [FileFinder::ByName / TTFiles]
 file = *.tt
 finder = TTFiles


Regular expression substitution used to generate the output filenames. By default this is

 output_regex = /\.tt$//

which generates a for each


Passed as TRIM to the constructor for Template::Tiny.


Specify additional variables for use by your template. The format is name = value so to specify foo = 1 and bar = 'hello world' you would include this in your dist.ini:

 var = foo = 1
 var = bar = hello world


If set to a true value, existing files in the source tree will be replaced, if necessary.


If set to a true value, the original template files will NOT be included in the built distribution.


$plugin->gather_files( $arg )

This method processes the TT files and injects the results into your dist.


This method is used to munge files that need to be replaced instead of injected.


This method is used to prune the original templates if the prune attribute is set.


Returns list of attributes that can be specified multiple times.


Why would you even need templates that get processed when you build your distribution anyway? There are many useful Dist::Zilla plugins that provide mechanisms for manipulating POD and Perl after all. I work on Perl distributions that are web apps that include CSS and JavaScript, and I needed a way to get the distribution version into the JavaScript. This seemed to be the clearest and most simple way to go about this.

First of all, I have a share directory called public that gets installed via [ShareDir].

 dir = public

Next I use this plugin to process files in the appropriate directory, so that .js files are produced.

 [FileFinder::ByName / JavaScriptTTFiles]
 dir = public/js
 file = *
 finder = JavaScriptTTFiles
 replace = 1
 prune = 1

Finally, I create a file

 if(PlugAuth === undefined) var PlugAuth = {};
 if(PlugAuth.UI === undefined) PlugAuth.UI = {};
 PlugAuth.UI.Name = 'PlugAuth WebUI';
 PlugAuth.UI.VERSION = '[% dzil.version %]';

which gets processed and used when the distribution is built and later installed. I also create a version.js file in the same directory so that I can use the distribution without having to build it.

 if(PlugAuth === undefined) var PlugAuth = {};
 if(PlugAuth === undefined) PlugAuth.UI = {};
 PlugAuth.UI.Name = 'PlugAuth WebUI';
 PlugAuth.UI.VERSION = 'dev';

Now when I run it out of the checked out distribution I get dev reported as the version and the actual version reported when I run from an installed copy.

There are probably other use cases and ways to get yourself into trouble.


Graham Ollis <>


This software is copyright (c) 2012 by Graham Ollis.

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