Search code examples
perlmojolicious

What is the name for inline/text/json with regard to Mojolicious handlers?


What is the name of the thing on the side of the fat-arrow in

$c->render(inline => 'The result is <%= 1 + 1 %>.');
$c->render(text => 'I ♥ Mojolicious!');
$c->render(json => {foo => [1, 'test', 3]});

And how can I write my own?


Solution

  • The arguments to render just set stash values internally. That's why they don't have a name. It seems these are special stash values that Mojolicious::Renderer uses.

    If you want to creaet a special thing that render special stuff, the way is with a handler,

    https://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Adding-your-favorite-template-system