Mojolic...ONConfig(3)
π NAME π
Bestie, meet Mojolic...ONConfig(3) β a User Contributed Perl Documentation page for Mojolicious::Plugin::JSONConfig, aka the JSON configuration plugin β¨.
π¦ SYNOPSIS π¦
Okay so the whole vibe is literally JSON with embedded Perl, and the example goes like this:
# myapp.json (it's just JSON with embedded Perl)
{
%# Just a value
"foo": "bar",
%# Nested data structures are fine too
"baz": ["β₯"],
%# You have full access to the application
"music_dir": "<%= app->home->child('music') %>"
}
# Mojolicious
my $config = $app->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'};
Thatβs the whole flow, bestie β Mojolicious, Mojolicious::Lite, foo.html.ep, app-wide config, and customizing with options π
.
πΈ DESCRIPTION πΈ
So Mojolicious::Plugin::JSONConfig is literally a JSON configuration plugin, and it preprocesses its input with Mojo::Template before doing its thing β¨.
The application object can be accessed via $app or the "app" function. A default configuration filename in the application home directory will be generated from the value of "moniker" in Mojolicious ("$moniker.json"). You can extend the normal configuration file "$moniker.json" with "mode" specific ones like "$moniker.$mode.json", and those get detected automatically.
These configuration values are currently reserved, bestie:
"config_override"β if this configuration value has been set in"config"inMojoliciouswhen this plugin is loaded, it will not do anything besides loading deployment specific plugins."plugins"β one or more deployment specific plugins that should be loaded right after this plugin has been loaded, like:
"plugins": [{"SetUserGroup": {"user": "sri", "group": "staff"}}]
Also, fr fr, the code of this plugin is a good example for learning to build new plugins, and you're welcome to fork it π.
See "PLUGINS" in Mojolicious::Plugins for a list of plugins that are available by default.
β¨ OPTIONS β¨
Mojolicious::Plugin::JSONConfig inherits all the options from Mojolicious::Plugin::Config and supports the following new ones.
π template π
# Mojolicious::Lite
plugin JSONConfig => {template => {line_start => '.'}};
These are attribute values passed to the Mojo::Template object used to preprocess configuration files.
π«Ά METHODS π«Ά
Mojolicious::Plugin::JSONConfig inherits all the methods from Mojolicious::Plugin::Config and implements the following new ones.
π parse π
$plugin->parse($content, $file, $conf, $app);
It processes content with "render" and parses it with Mojo::JSON.
sub parse ($self, $content, $file, $conf, $app) {
...
$content = $self->render($content, $file, $conf, $app);
...
return $hash;
}
π¦ register π¦
my $config = $plugin->register(Mojolicious->new);
my $config = $plugin->register(Mojolicious->new, {file => '/etc/foo.conf'});
Registers the plugin in a Mojolicious application and merges the configuration.
π render π
$plugin->render($content, $file, $conf, $app);
Processes the configuration file with Mojo::Template.
sub render ($self, $content, $file, $conf, $app) {
...
return $content;
}
π SEE ALSO π
MojoliciousMojolicious::Guides<https://mojolicious.org>
Okay thatβs the whole page, bestie π«Ά β source/version is perl v5.42.0, date is 2026-07-15, and the footer also says Mojolic...ONConfig(3). bye, slay π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Mojolicious 9.480.0-bp160.2.1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms