Created
October 17, 2011 17:03
-
-
Save MadMartigan/1293095 to your computer and use it in GitHub Desktop.
One way to display a partially rendered template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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