Renee Baecker > Mojolicious-Plugin-CSSLoader-0.03 > Mojolicious::Plugin::CSSLoader

Download:
Mojolicious-Plugin-CSSLoader-0.03.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.03   Source   Latest Release: Mojolicious-Plugin-CSSLoader-0.04

NAME ^

Mojolicious::Plugin::CSSLoader - move css loading to the end of the document

VERSION ^

version 0.03

SYNOPSIS ^

In your startup:

    sub startup {
        my $self = shift;
  
        # do some Mojolicious stuff
        $self->plugin( 'CSSLoader' );

        # more Mojolicious stuff
    }

In your template:

    <% css_load('css_file.css') %>

HELPERS ^

This plugin adds a helper method to your web application:

css_load

This method requires at least one parameter: The path to the JavaScript file to load. An optional second parameter is the configuration. You can switch off the base for this CSS file this way:

  # <link rel="stylesheet" href="$base/css_file.css"/>
  <% css_load('css_file.css') %>
  
  # <link rel="stylesheet" href="http://domain/css_file.css"/>
  <% css_load('http://domain/css_file.css', {no_base => 1});

HOOKS ^

When you use this module, a hook for after_render is installed. That hook inserts the <link> tag at the end of the <head> part or at the start of the document.

METHODS ^

register

Called when registering the plugin. On creation, the plugin accepts a hashref to configure the plugin.

    # load plugin, alerts are dismissable by default
    $self->plugin( 'CSSLoader' );

Configuration

    $self->plugin( 'CSSLoader' => {
        base  => 'http://domain/css',  # base for all CSS files
        media => 'screen',             # media setting (default: none)
    });

NOTES ^

This plugin uses the stash key __CSSLOADERFILES__, so you should avoid using this stash key for your own purposes.

AUTHOR ^

Renee Baecker <reneeb@cpan.org>

COPYRIGHT AND LICENSE ^

This software is Copyright (c) 2013 by Renee Baecker.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)
syntax highlighting: