Mojolicious::Plugin::JsonConfig - JSON Configuration Plugin
# myapp.json { "foo" : "bar", "music_dir" : "<%= app->home->rel_dir('music') %>" } # Mojolicious $self->plugin('json_config'); # Mojolicious::Lite plugin 'json_config'; # Reads myapp.json by default and puts the parsed version into the stash my $config = $self->stash('config'); # Everything can be customized with options my $config = plugin json_config => { file => '/etc/myapp.conf', stash_key => 'conf' };
Mojolicous::Plugin::JsonConfig is a JSON configuration plugin that preprocesses it's input with Mojo::Template.
The application object can be accessed via $app or the app helper. You can extend the normal config file myapp.json with mode specific ones like myapp.$mode.json.
$app
app
myapp.json
mode
myapp.$mode.json
# Mojolicious::Lite plugin json_config => {default => {foo => 'bar'}};
# Mojolicious::Lite plugin json_config => {ext => 'conf'};
File extension of config file, defaults to json.
json
# Mojolicious::Lite plugin json_config => {file => 'myapp.conf'}; plugin json_config => {file => '/etc/foo.json'};
By default myapp.json is searched in the application home directory.
# Mojolicious::Lite plugin json_config => {stash_key => 'conf'};
# Mojolicious::Lite plugin json_config => {template => {line_start => '.'}};
Mojolicious::Plugin::JsonConfig inherits all methods from Mojolicious::Plugin and implements the following new ones.
register
$plugin->register;
Register plugin hooks in Mojolicious application.
Mojolicious, Mojolicious::Guides, http://mojolicious.org.
To install Mojolicious, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious
CPAN shell
perl -MCPAN -e shell install Mojolicious
For more information on module installation, please visit the detailed CPAN module installation guide.