Text::MicroTemplate::DataSection - Render Text::MicroTemplate from __DATA__.
use Text::MicroTemplate::DataSection 'render_mt'; # Functional interface -- reads template from caller package __DATA__ $html = render_mt('index'); # render index.mt # OO - allows reading from other packages my $mt = Text::MicroTemplate::DataSection->new( package => $package ); $html = $mt->render('index'); # support Text::MicroTemplate::Extended with 'Ex' postfix. use Text::MicroTemplate::DataSectionEx 'render_mt'; $html = render_mt('child'); # template inheritance also supported __DATA__ @@ index.mt <html> <body>Hello</body> </html> @@ base.mt <html> <body><? block body => sub { ?>default body<? } ?></body> </html> @@ child.mt ? extends 'base'; ? block body => sub { child body ? } # endblock body
Text::MicroTemplate::DataSection is simple wrapper module allows you to render MicroTemplate template from __DATA__ section.
This module based Text::MicroTemplate::File, if you want to use extended feature such as template inheritance, macro or etc by Text::MicroTemplate::Extended, use "Text::MicroTemplate::DataSectionEx" instead of "Text::MicroTemplate::DataSection".
Text::MicroTemplate, Text::MicroTemplate::Extended, Data::Section::Simple.
Daisuke Murase <typester@cpan.org>
Copyright (c) 2010 by KAYAC Inc.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install Text::MicroTemplate::DataSection, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::MicroTemplate::DataSection
CPAN shell
perl -MCPAN -e shell install Text::MicroTemplate::DataSection
For more information on module installation, please visit the detailed CPAN module installation guide.