Skip to content

Instantly share code, notes, and snippets.

@anazawa
Created March 7, 2012 14:27
Show Gist options
  • Select an option

  • Save anazawa/1993446 to your computer and use it in GitHub Desktop.

Select an option

Save anazawa/1993446 to your computer and use it in GitHub Desktop.
MyApp::View::MT
package MyApp::View::MT;
use strict;
use warnings;
use parent 'Exporter';
use Text::MicroTemplate::Extended;
our @EXPORT_OK = qw( render_mt );
sub import {
my $caller = scalar caller;
$caller->new_hook( 'render_mt' );
__PACKAGE__->export_to_level( 1, @_ );
}
sub render_mt {
my ( $self, $template, @args ) = @_;
my %option = (
include_path => $self->tmpl_path,
template_args => {
c => $self,
q => $self->query,
cfg => scalar $self->cfg,
},
);
$self->call_hook( 'render_mt', \%option );
my $mt = Text::MicroTemplate::Extended->new( %option );
$mt->render( $template, @args )->as_string;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment