Mojolicious::Plugin::Mobi - Mojolicious Plugin
# Mojolicious # Register plugin Mobi and its helper to your application $self->plugin('Mobi'); # One way of how to use it $self->routes->route("/")->requires(mobile=>1)->to("Mobile#index"); # or another $self->render(text=>"You are mobile.") if $self->is_mobile; # Mojolicious::Lite # Register plugin Mobi and its helper to your application plugin 'Mobi'; # Use the helper anywhere within your app get '/' => sub { if (is_mobile()) { redirect_to("http://m.example.com"); } } # or hook it up in the route as a requirement get '/' => (mobile => 1) => sub { my $self = shift; $self->render(text => "This is a mobile version of this site."); };
Mojolicious::Plugin::Mobi is a Mojolicious plugin. This module provides a helper method is_mobile and route condition so it is easier to use in a dispatcher.
Mojolicious::Plugin::Mobi inherits all methods from Mojolicious::Plugin and implements the following new ones.
register
$plugin->register;
Register plugin in Mojolicious application.
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in '# Register'. Assuming UTF-8
To install Mojolicious::Plugin::Mobi, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::Mobi
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::Mobi
For more information on module installation, please visit the detailed CPAN module installation guide.