| Module-New documentation | Contained in the Module-New distribution. |
Module::New::Template
my $text = Module::New::Template->render('<% $c->module %>');
As of 0.02, Module::New uses a Mojo::Template-like template engine. See Mojo::Template for how to write templates.
takes a template, and returns a rendered text. Note that $c represents the Module::New context (which is passed to the template internally).
Kenichi Ishigaki, <ishigaki@cpan.org>
Copyright (C) 2009 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Module-New documentation | Contained in the Module-New distribution. |
package Module::New::Template; use strict; use warnings; use Text::MicroTemplate (); # XXX: I'm still wondering if I should use Mojo::Template here... my $ENGINE = Text::MicroTemplate->new( expression_mark => '=', line_start => '%', tag_start => '<%', tag_end => '%>', ); sub render { my ($self, $template) = @_; $template = '% my $c = shift;'."\n".$template; $ENGINE->parse($template)->build->(Module::New->context)->as_string; } 1; __END__