Created
January 3, 2012 16:27
-
-
Save picandocodigo/1555633 to your computer and use it in GitHub Desktop.
Primeras pruebas con Mojolicious
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
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é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