The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Template::Provider::Markdown::Pandoc - expand Markdown templates to HTML

SYNOPSIS

    use Template;
    use Template::Provider::Markdown::Pandoc;

    my $tt = Template->new(
      LOAD_TEMPLATES = [ Template::Provider::Markdown::Pandoc->new ],
    );

    $tt->process('template.md', \%vars)

DESCRIPTION

Template::Provider::Markdown::Pandoc is an extension to the Template Toolkit which automatically converts Markdown files into HTML 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 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.

If you want to pre-process all template files, then you need to explicitly set the EXTENSION parameter to undef.

    y $tt = Template->new(
      LOAD_TEMPLATES = [
        Template::Provider::Markdown::Pandoc->new(
          EXTENSION => undef,
        },
      ],
    );

Template::Provider::Markdown

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.

  1. 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.

  2. 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.

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.

SEE ALSO

Template, Template::Provider, Pandoc, Template::Provider::Markdown.