Mojolicious::Plugin::Component

Module-based Component Rendering

Module-based Component Rendering Plugin

method: register

package App;

use Mojo::Base 'Mojolicious';

package App::Component::Image;

use Mojo::Base 'Mojolicious::Component';

has alt => 'random';
has height => 126;
has width => 145;
has src => '/random.gif';

1;

# __DATA__
#
# @@ component
#
# <img
#   alt="<%= $component->alt %>"
#   height="<%= $component->height %>"
#   src="<%= $component->src %>"
#   width="<%= $component->width %>"
# />

package main;

my $app = App->new;

my $component = $app->plugin('component');

my $image = $app->component->use('image');

my $rendered = $image->render;

Mojolicious::Plugin

This package provides Mojolicious module-based component rendering plugin.

The register method registers one or more component builders in the Mojolicious application. The configuration information can be provided when registering the plugin by calling plugin during setup, or by specifying the data in the application configuration under the key component. By default, if no configuration information is provided the plugin will register a builder labeled use which will load components under the application's Component namespace.

register(InstanceOf["Mojolicious"] $app, Maybe[HashRef] $config) : Object

=example-1 register

package main;

use Mojolicious::Plugin::Component;

my $app = Mojolicious->new;

my $component = Mojolicious::Plugin::Component->new;

$component = $component->register($app);

=example-2 register

package main;

use Mojolicious::Plugin::Component;

my $app = Mojolicious->new;

my $component = Mojolicious::Plugin::Component->new;

$component = $component->register($app, {
  v1 => 'App::V1::Component',
  v2 => 'App::V2::Component',
});

# my $v1 = $app->component->v1('image');
# my $v2 = $app->component->v2('image');

=example-3 register

package main;

use Mojolicious::Plugin::Component;

my $app = Mojolicious->new;

my $component = Mojolicious::Plugin::Component->new;

$component = $component->register($app, {
  v1 => 'App::V1::Component',
  v2 => 'App::V2::Component',
});

# my $v1 = $app->component->v1('image' => (
#   src => '/random-v1.gif',
# ));

# my $v2 = $app->component->v2('image' => (
#   src => '/random-v2.gif',
# ));

9 POD Errors

The following errors were encountered while parsing the POD:

Around line 10:

Unknown directive: =name

Around line 16:

Unknown directive: =tagline

Around line 22:

Unknown directive: =abstract

Around line 28:

Unknown directive: =includes

Around line 34:

Unknown directive: =synopsis

Around line 74:

Unknown directive: =inherits

Around line 80:

Unknown directive: =description

Around line 86:

Unknown directive: =method

Around line 96:

Unknown directive: =signature