Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Perl
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/Mojolicious/Plugin
t
.gitignore
README.pod
dist.ini

README.pod

NAME

Mojolicious::Plugin::Sugar - Some sweet stuff for Mojolicious

VERSION

version 0.002

SYNOPSIS

    # Mojolicious
    $self->plugin('Sugar');

    # Mojolicious::Lite
    plugin 'Sugar';

    # To add more than one flash values, for messages, for example.
    $self->flash_add_to( 'messages' => 'message one' );
    $self->flash_add_to( 'messages' => 'message two' );
    $self->flash_add_to( 'messages' => 'message three', 'message four' );
    $self->redirect_to( '/list' );

    @@ list.html.ep
    % foreach my $msg ( @{ flash messages } ) {
    <li><%= $msg %>
    % }

    # Shortcut to process HTML::FormHandler form 
    my $form = MyApp::Form::Add->new;
    $form->process( $self->params->to_hash );

    if ($form->validated) {
      [...]
    }
    else {
      [...]
    }

DESCRIPTION

Mojolicious::Plugin::Sugar is a Mojolicious plugin that adds few convenience helpers.

NAME

Mojolicious::Plugin::Sugar - sugary helpers for your Mojolicious app

HELPERS

flash_add_to

    $self->flash_add_to( 'messages' => 'message one' );
    $self->flash_add_to( 'messages' => 'message two' );

This helper allow you to add multiple values into flash variables. It creates referenced array when first called and all next calls will add additional elements into this array. Later in your template you can do something like this:

    @@ list.html.ep
    % foreach my $msg ( @{ flash messages } ) {
    <li><%= $msg %>
    % }

You can also specify more than one value in one call:

    $self->flash_add_to( 'messages' => 'message three', 'message four' );

To overwrite flash variable simply use standard $self->flash() call.

AUTHOR

Pavel A. Karoukin <pavel@karoukin.us>

BUGS

Please report any bugs or feature requests to Github https://github.com/hippich/perl-mojolicious-plugin-sugar

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicio.us.

AUTHOR

Pavel A. Karoukin <pavel@karoukin.us>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Pavel A. Karoukin <pavel@karoukin.us>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Something went wrong with that request. Please try again.