Skip to content

Commit

Permalink
better examples for config plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 20, 2013
1 parent dcc4f1f commit 2fec633
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,4 +1,6 @@

4.03 2013-05-21

4.02 2013-05-20
- Fixed extends, layout and title helpers not to generate unnecessary log
messages.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -41,7 +41,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Top Hat';
our $VERSION = '4.02';
our $VERSION = '4.03';

sub AUTOLOAD {
my $self = shift;
Expand Down
5 changes: 4 additions & 1 deletion lib/Mojolicious/Plugin/Config.pm
Expand Up @@ -64,23 +64,26 @@ Mojolicious::Plugin::Config - Perl-ish configuration plugin
=head1 SYNOPSIS
# myapp.conf
# myapp.conf (it's just Perl returning a hash)
{
foo => "bar",
music_dir => app->home->rel_dir('music')
};
# Mojolicious
my $config = $self->plugin('Config');
say $config->{foo};
# Mojolicious::Lite
my $config = plugin 'Config';
say $config->{foo};
# foo.html.ep
%= $config->{foo}
# The configuration is available application wide
my $config = app->config;
say $config->{foo};
# Everything can be customized with options
my $config = plugin Config => {file => '/etc/myapp.stuff'};
Expand Down
5 changes: 4 additions & 1 deletion lib/Mojolicious/Plugin/JSONConfig.pm
Expand Up @@ -40,23 +40,26 @@ Mojolicious::Plugin::JSONConfig - JSON configuration plugin
=head1 SYNOPSIS
# myapp.json
# myapp.json (it's just JSON with embedded Perl)
{
"foo" : "bar",
"music_dir" : "<%= app->home->rel_dir('music') %>"
}
# Mojolicious
my $config = $self->plugin('JSONConfig');
say $config->{foo};
# Mojolicious::Lite
my $config = plugin 'JSONConfig';
say $config->{foo};
# foo.html.ep
%= $config->{foo}
# The configuration is available application wide
my $config = app->config;
say $config->{foo};
# Everything can be customized with options
my $config = plugin JSONConfig => {file => '/etc/myapp.conf'};
Expand Down

0 comments on commit 2fec633

Please sign in to comment.