NAME

Mojolicious::Plugin::ContextResources - Mojolicious plugin for automatic use javascript and stylesheet like a templates, by controller/action path.

SYNOPSIS

# Automatically add link to
# public/css/foo/bar.css and public/js/foo/bar.js
# if exists

# Mojolicious
sub startup {
    my ($self) = @_;
    $self->plugin('ContextResources');
    $self->routes->get("/test")->to('foo#bar');
}

# Mojolicious::Lite
plugin 'ContextResources';
get '/test' => {template => 'foo/bar'};

__DATA__
@@ foo/bar.html.ep
% layout 'default';

@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
        %= stylesheet_context;
    </head>
    <body>
        %= content
        <footer>
            %= javascript_context;
        </footer>
    </body>
</html>

DESCRIPTION

Mojolicious::Plugin::ContextResources use controller and action, or template for automatic add js and css if it present.

HELPERS

url_context_stylesheet

Get Mojo::URL for current context stylesheet.

url_context_javascript

Get Mojo::URL for current context javascript.

stylesheet_context

Like stylesheet helper for for current context stylesheet.

javascript_context

Like javascript helper for for current context javascript.

OPTIONS

home

Path to basic folder. Default from Mojo::Home

public

Public folder. Default: public.

css

CSS folder. Default: css.

js

JS folder. Default: js.

SEE ALSO

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