Action List implementation #1867
michaelfung
started this conversation in
General
Replies: 1 comment 3 replies
-
Can you render separate templates using Separate templates and methods sub bar { return shift() ^ 2 }
sub foo { return shift() * -1 }
sub parse($c) {
my $m = $c->param('m') // 'default';
my $p = $c->param('p') // 0;
my $method = {foo => \&foo, bar => \&bar}->{$m};
return $c->render(action => $m, p => $method->($p)) if $method;
return $c->render(action => 'default', status => 400);
} foo.html.ep foo with p value <%= $p %> There's also shortcuts and placeholder types, but that might not fit with your route specification. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I need to process many directives coming into a single endpoint. I use an action list inside a controller like below:
Is there room for improvement or better alternatives? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions