Navigation Menu

Skip to content

Commit

Permalink
explain how Mojo::Loader works
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 21, 2015
1 parent 8c92714 commit f4a5f89
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
24 changes: 23 additions & 1 deletion lib/Mojo/Loader.pm
Expand Up @@ -121,7 +121,29 @@ Mojo::Loader - Loader
=head1 DESCRIPTION
L<Mojo::Loader> is a class loader and plugin framework.
L<Mojo::Loader> is a class loader and plugin framework. It allows multiple
files to be stored in the C<DATA> section of a class, which can then be
accessed individually.
package Foo;
1;
__DATA__
@@ test.txt
This is the first file.
@@ test2.html (base64)
VGhpcyBpcyB0aGUgc2Vjb25kIGZpbGUu
@@ test
This is the
third file.
Each file has a header starting with C<@@>, followed by the file name and
optional instructions for decoding its content. Currently only the Base64
encoding is supported, which can be quite convenient for the storage of binary
data.
=head1 FUNCTIONS
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Command.pm
Expand Up @@ -219,7 +219,7 @@ directory.
my $data = $command->render_data('foo_bar', @args);
Render a template from the C<DATA> section of the command class with
L<Mojo::Template>.
L<Mojo::Loader> and L<Mojo::Template>.
=head2 render_to_file
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Renderer.pm
Expand Up @@ -289,8 +289,8 @@ Renderer cache, defaults to a L<Mojo::Cache> object.
my $classes = $renderer->classes;
$renderer = $renderer->classes(['main']);
Classes to use for finding templates in C<DATA> sections, first one has the
highest precedence, defaults to C<main>.
Classes to use for finding templates in C<DATA> sections with L<Mojo::Loader>,
first one has the highest precedence, defaults to C<main>.
# Add another class with templates in DATA section
push @{$renderer->classes}, 'Mojolicious::Plugin::Fun';
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Static.pm
Expand Up @@ -175,8 +175,8 @@ L<Mojolicious::Static> implements the following attributes.
my $classes = $static->classes;
$static = $static->classes(['main']);
Classes to use for finding files in C<DATA> sections, first one has the
highest precedence, defaults to C<main>.
Classes to use for finding files in C<DATA> sections with L<Mojo::Loader>,
first one has the highest precedence, defaults to C<main>.
# Add another class with static files in DATA section
push @{$static->classes}, 'Mojolicious::Plugin::Fun';
Expand Down

0 comments on commit f4a5f89

Please sign in to comment.