Snippets

sironekotoro Mojoliciousのタグに変数を入れられると何が嬉しいか

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

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

app->start;
__DATA__

@@ index.html.ep
% layout 'default';
<h1>Welcome to the Mojolicious real-time web framework!</h1>

% for my $n (1..6) {
    <h<%=$n%>>hoge</h<%=$n%>>
% }

@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
  <head><title><%= title %></title></head>
  <body><%= content %></body>
</html>

Comments (0)

HTTPS SSH

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