Template::Provider::Markdown::Pandoc - expand Markdown templates to HTML
use Template; use Template::Provider::Markdown::Pandoc; my $tt = Template->new( LOAD_TEMPLATES = [ Template::Provider::Markdown::Pandoc->new ], ); $tt->process('template.md', \%vars)
Template::Provider::Markdown::Pandoc is an extension to the Template Toolkit which automatically converts Markdown files into HTML 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 can accept all of the standard parameters that can be passed to any Template provider module. See Template::Provider for the full list.
This module accepts one extra parameter, EXTENSION, which defines the file extension that is used to identify Markdown files. Only template files with this extension will be pre-processed by this module. The default extension is 'md', so you don't need to pass an EXTENSION parameter if you're happy to use that extension.
EXTENSION
If you want to pre-process all template files, then you need to explicitly set the EXTENSION parameter to undef.
undef
y $tt = Template->new( LOAD_TEMPLATES = [ Template::Provider::Markdown::Pandoc->new( EXTENSION => undef, }, ], );
There is already a module called Template::Provider::Markdown available on CPAN, so why did I write another, very similar-sounding, module? There are two reasons.
Template::Provider::Markdown uses Text::Markdown to do the conversion and I've found a few problems with the Markdown conversion in that module. This module uses pandoc (see http://pandoc.org/) a very powerful and flexible tool for converting between document formats.
pandoc
Template::Provider::Markdown assumes that all of your templates are in Markdown and converts them all. That didn't fit with what I wanted to. I only wanted to convert specific templates.
However, because I'm using file extensions to recognise the templates that need conversion, this module can only be used to pre-process templates that are stored in files. This isn't a restriction in my use cases.
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, Template::Provider::Markdown.
To install Template::Provider::Markdown::Pandoc, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Template::Provider::Markdown::Pandoc
CPAN shell
perl -MCPAN -e shell install Template::Provider::Markdown::Pandoc
For more information on module installation, please visit the detailed CPAN module installation guide.