NAME
Template::Provider::Pandoc - pre-process templates with Pandoc
SYNOPSIS
use Template;
use Template::Provider::Pandoc;
my $tt = Template->new(
LOAD_TEMPLATES => [ Template::Provider::Pandoc->new ],
);
$tt->process('template.md', \%vars)
DESCRIPTION
Template::Provider::Pandoc is an extension to the Template Toolkit which automatically processes templates using Pandoc before they are processed by TT.
USAGE
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.
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 three extra parameters, EXTENSIONS
, which defines the file extensions that is used to identify files that require conversion, OUTPUT_FORMAT
which defines the the format that template will be converted into and STRIP_FRONT_MATTER
which will remove Jekyll-style front matter from the file content before returning it.
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
$ pandoc --list-output-values
at a command line.
STRIP_FRONT_MATTER
is a flag that is either true or false. The default value is false. If it is true then this module will remove any Jekyll-style front matter from the file contents before returning them.
Jekyll-style front matter is a format used by Jekyll and other, similar, static site builders. It is a fragmant of YAML that is inserted at the top of the file between two lines that consist only of three dashes, like this:
---
title: Title of the page
author: Joe Author
tags:
- list
- of
-tags
---
The current implementation doesn't check that the front matter is actually YAML. It simply removes everything from the first line of dashes to the second.
Template::Provider::Markdown::Pandoc
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!
AUTHOR
Dave Cross <dave@perlhacks.com>
COPYRIGHT
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.