Giter VIP home page Giter VIP logo

mojox-loader's Introduction

NAME

MojoX::Loader - Loader of any Mojolicious Controller Modules in standalone script

SYNOPSIS

# script.pl

use MojoX::Loader;

# Load App::User controller (App/User.pm) uses the base application module App (App.pm)
my $user = MojoX::Loader->load(controller => 'App::User');

# or

# Load MyApp::User controller (MyApp/User.pm) uses the base application module MyApp (MyApp.pm)
my $user = MojoX::Loader->load(app => 'MyApp', controller => 'MyApp::User');

# call the _total method from MyApp::User
say $user->_total;

DESCRIPTION

MojoX::Loader is a module can load any Mojolicious Controller Modules in a standalone scripts (none Mojolicious scripts).

ATTRIBUTES

MojoX::Loader implements the following attributes.

app

my $app = $loader->app;
$app = $loader->app('MyApp');

Name of the base Mojolcious application, the default value is App.

controller

my $c = $loader->controller;
$c = $loader->controller('MyApp::User');

Name of the Mojolicious Controller, the default value is Mojolicious::Controller.

log

my $log = $loader->log;
$app = $loader->log(Mojo::Log->new);

The logging layer of your application, by default a Mojo::Log object with debug level and STDERR handler.

prefix

my $prefix = $loader->prefix;
$prefix = $loader->prefix('../../');

The prefix for any path in application, for example renderer root.

METHODS

MojoX::Loader inherits all methods from Mojo::Base and implements the following new ones.

load

my $user = MojoX::Loader->load(app => 'App', controller => 'App::User', prefix => '../../');

Load any Mojolicious Controller of application.

EXAMPLES

#!/usr/bin/env perl
use common::sense;
use lib qw(../.. ../../lib);

use MojoX::Loader;
my $user = MojoX::Loader->load(controller => 'App::User', prefix => '../../');

# call the method _total
say $user->_total;
<>;

# call the helper db
say $user->db;
<>;

# call the helper conf
say $user->conf('server')->{www};
<>;

# call the helper from App::Helpers
say $user->format_digital('1234567');
<>;

# render any template
say $user->render_partial('mail/test', format => 'mail');

SEE ALSO

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

AUTHOR

Anatoly Sharifulin <[email protected]>

BUGS

Please report any bugs or feature requests to bug-mojox-loader at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.htMail?Queue=MojoX-Loader. We will be notified, and then you'll automatically be notified of progress on your bug as we make changes.

COPYRIGHT & LICENSE

Copyright (C) 2011 by Anatoly Sharifulin.

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

mojox-loader's People

Contributors

sharifulin avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.