Snippets

Brian Medley Perl config file example

Created by Brian Medley
#!/usr/bin/env perl
use Mojolicious::Lite;

my $config = plugin 'Config';

get '/' => sub {
    my $c = shift;
    
    $c->render(template => 'index', from_config => $config->{joy});
};

app->start;

__DATA__

@@ index.html.ep
% layout 'default';
% title 'Welcome';
Welcome to the Mojolicious real-time web framework!
<%= stash('from_config') %>

@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
  <head><title><%= title %></title></head>
  <body><%= content %></body>
</html>
[bpm@Orfgum] c:~/playground>
[bpm@Orfgum] c:~/playground>cat config.conf
{
    joy => '12345',
};
[bpm@Orfgum] c:~/playground>

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.