Cataly...erView(3pm)

πŸ“¦
version 0.17 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Catalyst::Action::RenderView β€” the sensible default end action, bestie. It's giving "just works" energy. πŸŽ€


✨ SYNOPSIS ✨

sub end : ActionClass('RenderView') {}

That's it. That's the whole vibe. One line and you're slaying. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so listen. This action implements a sensible default end action. What does it do? It forwards to the first available view. That's the main character move. πŸ‘‘

BUT β€” and this is the important part, no cap β€” it will not do that if any of these are true:

  • $c->res->status is a 3xx code (redirection, not modified, etc.)
  • $c->res->status is 204 (no content)
  • $c->res->body has already been set

It also lets you pass dump_info=1 to the url to force a debug screen, but only while you're in debug mode. πŸ›βœ¨

And if you have more than one view (look at you, overachiever πŸ’œ), you can specify which one gets used with the default_view config setting and the current_view and current_view_instance stash keys. See Catalyst's $c->view($name) method β€” this module literally just calls $c->view with no argument. Simple. Iconic. Periodt.


🌸 METHODS 🌸

end

The default end action, bestie. You can override this in your application class whenever you need to β€” normal inheritance applies, so go off. 🫢


🧚 INTERNAL METHODS 🧚

execute

Dispatches control to superclasses, then forwards to the default View. That's the whole job description.

See "METHODS/action" in Catalyst::Action.


πŸ“ SCRUBBING OUTPUT πŸ“

So when you force debug with dump_info=1, RenderView is capable of removing classes from the objects in your stash. Like a little cleanup fairy. 🧹✨

By default it will replace any DBIx::Class ResultSource objects with the class name, which cleans up the debug output considerably. Huge glow-up for your terminal, fr fr.

But you can change what gets scrubbed by setting a list of classes in $c->config->{'Action::RenderView'}->{ignore_classes}. For instance:

$c->config->{'Action::RenderView'}->{ignore_classes} = [];

That's how you disable the functionality entirely. πŸ’€

You can also set config->{'Action::RenderView'}->{scrubber_func} to change what it does with the classes. For instance, this will undef it instead of putting in the class name:

$c->config->{'Action::RenderView'}->{scrubber_func} = sub { undef $_ };

Deprecation notice ⚠️

Okay so this plugin used to be configured by setting $c->config->{debug}. That configuration key is still supported in this release, but it is deprecated β€” so please use the 'Action::RenderView' namespace as shown above for configuration in new code. Don't be out here using deprecated keys, babe, it's not the move. πŸ™ˆ


🌈 EXTENDING 🌈

Wanna add something to an end action that gets called before rendering? Simply place it in the end method:

sub end : ActionClass('RenderView') {
    my ( $self, $c ) = @_;
    # do stuff here; the RenderView action is called afterwards
}

Wanna add things to an end action that get called after rendering? Set it up like this:

sub render : ActionClass('RenderView') { }

sub end : Private {
    my ( $self, $c ) = @_;
    $c->forward('render');
    # do stuff here
}

Two ways to do it, both valid, both slay. Choose your fighter. πŸ”₯


πŸ‘‘ AUTHORS πŸ‘‘

  • Marcus Ramberg <marcus@thefeed.no>
  • Florian Ragwitz <rafl@debian.org>

πŸ’œ CONTRIBUTOR πŸ’œ

Graham Knop <haarg@haarg.org>


This software is copyright (c) 2006 - 2009 by Marcus Ramberg and Florian Ragwitz.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. 🫢


Okay bestie, that's the whole page β€” this was Cataly...erView(3pm) from perl v5.40.0, dated 2024-10-28. Go forth and render those views, you absolute icon. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from