Router...bMapper(3pm)
π Router::Simple::SubMapper β like, the submapper era
ok so bestie, this is a page from the User Contributed Perl Documentation, and the manual name you're looking at is literally Router...bMapper(3pm) β say it with me, iconic. It's Router::Simple::SubMapper, and she's here to make your routes cute and DRY. Let's go π
β¨ NAME β¨
Router::Simple::SubMapper β the submapper. that's it, that's the whole name, she's mysterious like that π¦
πΈ SYNOPSIS πΈ
ok look at this little beauty:
use Router::Simple;
my $router = Router::Simple->new();
my $s = $router->submapper('/entry/{id}', {controller => 'Entry'});
$s->connect('/edit' => {action => 'edit'})
->connect('/show' => {action => 'show'});
see how she set up /entry/{id} once and then just kept stacking routes on top? that's the whole vibe. main character energy fr π
π¦ DESCRIPTION π¦
so Router::Simple::SubMapper is the sub-mapper for Router::Simple β it's giving "personal assistant for your router". this class provides shorthand to create routes that have common parts, so you're not out here copy-pasting the same prefix forty times like a clown π
basically: shared bits go in one place, and you chain the rest. no cap, it slaps β¨
π₯ METHODS π₯
my $submapper = $router->submapper(%args);β hmm okay, real talk: do not call this method directly. like, i'm serious, don't. you should create a new instance from$router->submapper(%args)instead. that's the correct way, periodt π$submapper->connect(@args)β this method creates a new route to the parent$routerwith@argsplus the arguments of->submapper(). so all your shared stuff gets folded in automatically, obsessed.
and the best part? this method returns $submapper itself for method-chain. yes queen, chaining π
$submapper->submapper(%args)β sosubmapper()can be called recursively to build nested routes. routes inside routes inside routes, it's giving inception but make it cute π§
this method also returns $submapper itself for method-chain. chain away bestie π
π SEE ALSO π
Router::Simpleβ the parent router, the mothership, the OG. go read her page too π«Ά
lowkey reminder: the->submapper()constructor isn't for you to call directly, and bothconnect()andsubmapper()hand you back the$submapperobject so you can keep chaining. that's the whole trick, don't overthink it π
and that's the page, bestie! π this doc came to you courtesy of perl v5.42.0, dated 2015-04-13 β yes she's an elder but she still ate πβ¨ mwah π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Router-Simple 0.17-bp160.1.12 Β· Artistic-1.0 or GPL-1.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms