Skip to content

Instantly share code, notes, and snippets.

@esobchenko
Created August 26, 2011 14:49
Show Gist options
  • Select an option

  • Save esobchenko/1173569 to your computer and use it in GitHub Desktop.

Select an option

Save esobchenko/1173569 to your computer and use it in GitHub Desktop.
{ # custom renderer <% include 'foo', handler => 'no' %>
package Mojolicious::Plugin::NoRenderer;
use Mojo::Base 'Mojolicious::Plugin';
use IO::File;
sub register {
my ( $self, $app, $options ) = @_;
$options ||= {};
$app->renderer->add_handler(
no => sub {
my ( $r, $c, $output, $options ) = @_;
my $file = $r->template_path($options);
my $fh = IO::File->new( $file, 'r' ) or die "failed to open $file: $!";
my $contents = do { local $/ = undef; <$fh> };
undef $fh;
$$output = $contents;
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment