The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojolicious::Plugin::DefaultHelpers - Default Helpers Plugin

SYNOPSIS

    # Mojolicious
    $self->plugin('default_helpers');

    # Mojolicious::Lite
    plugin 'default_helpers';

DESCRIPTION

Mojolicous::Plugin::DefaultHelpers is a collection of renderer helpers for Mojolicious. This is a core plugin, that means it is always enabled and its code a good example for learning to build new plugins.

Helpers

content
    <%= content %>

Insert content into a layout template.

content_for
    <% content_for foo => begin %>test<% end %>
    <%= content_for 'foo' %>

Append content to named buffer and retrieve it. Note that this helper is EXPERIMENTAL and might change without warning!

    <% content_for message => begin %>Hello <% end %>
    <% content_for message => begin %>world!<% end %>
    <%= content_for 'message' %>
dumper
    <%= dumper $foo %>

Dump a Perl data structure using Data::Dumper.

extends
    <% extends 'foo'; %>

Extend a template.

flash
    <%= flash 'foo' %>

Access flash values.

include
    <%= include 'menubar' %>
    <%= include 'menubar', format => 'txt' %>

Include a partial template.

layout
    <% layout 'green'; %>

Render this template with a layout.

memorize
    <%= memorize begin %>
        <%= time %>
    <% end %>
    <%= memorize {expires => time + 1} => begin %>
        <%= time %>
    <% end %>
    <%= memorize foo => begin %>
        <%= time %>
    <% end %>
    <%= memorize foo => {expires => time + 1} => begin %>
        <%= time %>
    <% end %>

Memorize block result in memory and prevent future execution. Note that this helper is EXPERIMENTAL and might change without warning!

param
    <%= param 'foo' %>

Access request parameters and routes captures.

session
    <%= session 'foo' %>

Access session values.

stash
    <%= stash 'foo' %>
    <% stash foo => 'bar'; %>

Access stash values.

title
    <% title 'Welcome!'; %>
    <%= title %>

Page title. Note that this helper is EXPERIMENTAL and might change without warning!

url_for
    <%= url_for %>
    <%= url_for 'index' %>
    <%= url_for 'index', foo => 'bar' %>

Generate URLs.

METHODS

Mojolicious::Plugin::DefaultHelpers inherits all methods from Mojolicious::Plugin and implements the following new ones.

register

    $plugin->register;

Register helpers in Mojolicious application.

SEE ALSO

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