Template::Provider::Pandoc - pre-process templates with Pandoc
use Template; use Template::Provider::Pandoc; my $tt = Template->new( LOAD_TEMPLATES = [ Template::Provider::Pandoc->new ], ); $tt->process('template.md', \%vars)
Template::Provider::Pandoc is an extension to the Template Toolkit which automatically processes templates using Pandoc before they are processed by TT.
Like any Template provider module, you will usually use this module by creating an instance of the object and passing that in the LOAD_TEMPLATES parameter to the Template module's new method.
LOAD_TEMPLATES
new
This module accepts all of the standard parameters that can be passed to any Template provider module. See Template::Provider for the full list.
This module accepts two extra parameters, EXTENSIONS, which defines the file extensions that is used to identify files that require conversion, and OUTPUT_FORMAT which defines the the format that template will be converted into.
EXTENSIONS
OUTPUT_FORMAT
EXTENSIONS is a hash reference. The default is to only handle Markdown files (which are identified by the extension .md). You can get a full list of the allowed input formats by running
$ pandoc --list-input-formats
at a command line.
The EXTENSIONS option supports one special option. If you use `*` as an extenstion, then files with any extension will be converted using the supplied format. So code like:
my $provider = Template::Provider::Pandoc( EXTENSIONS => { '*' => 'markdown' }, );
will lead to all files being pre-processed as Markdown files before being handed to the Template Toolkit.
OUTPUT_FORMAT is a single, scalar value containing the name of an output format. The default value is html. You can get a full list of the allowed putput values by running
html
$ pandoc --list-output-values
This module is a successor to Template::Provider::Markdown::Pandoc. This replacement module has all the functionality of the older module, and a lot more besides. And, as a bonus, it has a shorter name!
Dave Cross <dave@perlhacks.com>
Copyright (c) 2017 Magnum Solutions Ltd. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Template, Template::Provider, Pandoc.
To install Template::Provider::Pandoc, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Template::Provider::Pandoc
CPAN shell
perl -MCPAN -e shell install Template::Provider::Pandoc
For more information on module installation, please visit the detailed CPAN module installation guide.