Created by
sironekotoro
| #!/usr/bin/env perl
use Mojolicious::Lite;
my $color = 'black';
get '/' => sub {
my $c = shift;
$c->stash( color => $color );
$c->render( template => 'index' );
};
get '/color' => sub {
my $c = shift;
$color = $c->param('color');
$c->redirect_to('/');
};
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'Welcome';
<h1>Welcome to the Mojolicious real-time web framework!</h1>
<form action="/color">
<input type="radio" name="color" value="black">黒
<input type="radio" name="color" value="red">赤
<input type="radio" name="color" value="blue">青
<input type="radio" name="color" value="green">緑
<button type="submit">change</button>
</form>
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<%= include 'test.css' =%>
</head>
<body><%= content %></body>
</html>
@@ test.css.html.ep
%= stylesheet begin
h1{
color:<%=$color%>;
}
%= end
|