Skip to content

Instantly share code, notes, and snippets.

@sshaw
Created April 4, 2012 05:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sshaw/2298052 to your computer and use it in GitHub Desktop.
Save sshaw/2298052 to your computer and use it in GitHub Desktop.
Mojolicious Twitter Bootstrap Flash/Stash Alerts
use Mojo::ByteStream;
app->helper(alerts => sub {
my $c = shift;
my $html = '';
for my $message (qw|success info error|) {
my $css = "alert alert-$message";
if($c->flash($message)) {
$html .= $c->tag('div', class => $css, $c->flash($message));
}
if($c->stash($message)) {
$html .= $c->tag('div', class => $css, $c->stash($message));
}
}
b($html);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment