Skip to content

Instantly share code, notes, and snippets.

@picandocodigo
Created January 3, 2012 16:27
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 picandocodigo/1555633 to your computer and use it in GitHub Desktop.
Save picandocodigo/1555633 to your computer and use it in GitHub Desktop.
Primeras pruebas con Mojolicious
use Mojolicious::Lite;
use strict;
use warnings;
get '/' => sub{
my $self = shift;
$self->render('index');
};
get '/:name' => sub{
my $self = shift;
my $name = $self->param('name');
#Pasar a mayúsculas el nombre:
$name =~ s/\b([a-z])(\w+)\b/\u$1$2/g;
$self->render('hello');
};
app->start;
__DATA__
@@ layouts/wrapper.html.ep
<div class="wrapper" style="width: 500px; background: #000; color: #fff; padding: 20px; border-radius: 15px;">
<h1><%= title %></h1>
<%= content %></div>
<div class="footer" style="float: right">
<small>Powered by <a href="http://mojolicio.us" title="Mojolicious">Mojolicious</a></small>
</div>
@@ index.html.ep
% title 'Bienvenido';
% layout 'wrapper';
Hola, ingresa tu nombre en la URL despu&eacute;s de la barra /
@@ hello.html.ep
% title 'Saludo';
% layout 'wrapper';
Hola <%= $name %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment