package Template::Provider::Markdown; use 5.008; use warnings; use strict; use Text::Markdown 'markdown'; use base qw( Template::Provider ); =head1 NAME Template::Provider::Markdown - Markdown as template body, no HTML. =head1 VERSION Version 0.04 =cut our $VERSION = '0.04'; =head1 SYNOPSIS This module import Markdown syntax as the body of template. You don't live with HTML anymore. use Template; use Template::Provider::Markdown; my $tt = Template->new( LOAD_TEMPLATES => [ Template::Provider::Markdown->new ] ); my $template = 'My name is [% author %]'; print $tt->process(\$template, { author => "Charlie" });
My name is Charlie
=head1 FUNCTIONS =head2 _load() This function is the entry point as a Template::Provider. You shouldn't call any functions in this module, but rather just use this module as the way in SYNOPSIS. =cut sub _load { my $self = shift; my ($data, $error) = $self->SUPER::_load(@_); $data->{text} = markdown($data->{text}); return ($data, $error); } =head1 AUTHOR Kang-min Liu, C<<