Skip to content

Instantly share code, notes, and snippets.

@MadMartigan
Created October 17, 2011 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MadMartigan/1293095 to your computer and use it in GitHub Desktop.
Save MadMartigan/1293095 to your computer and use it in GitHub Desktop.
One way to display a partially rendered template
#!/usr/bin/env perl
use Mojolicious::Lite;
# Documentation browser under "/perldoc"
plugin 'PODRenderer';
get '/welcome' => sub {
my $self = shift;
my $guide = $self->render('guide', partial => 1);
$self->render(
template => 'index',
guide => $guide );
};
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'Welcome';
Welcome to Mojolicious!
<%= stash("guide") %>
@@ guide.html.ep
I am a partially rendered template!
@@ layouts/default.html.ep
<!doctype html><html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment