Commit | Line | Data |
---|---|---|
9a76221e | 1 | package Catalyst::Action::Serialize::View; |
930013e6 | 2 | use Moose; |
3 | use namespace::autoclean; | |
9a76221e | 4 | |
930013e6 | 5 | extends 'Catalyst::Action'; |
9a76221e | 6 | |
a042dad0 | 7 | our $VERSION = '0.83'; |
6edee33e | 8 | $VERSION = eval $VERSION; |
9 | ||
9a76221e | 10 | sub execute { |
11 | my $self = shift; | |
12 | my ( $controller, $c, $view ) = @_; | |
faf5c20b | 13 | |
14 | my $stash_key = ( | |
07682cbc | 15 | $controller->{'serialize'} ? |
16 | $controller->{'serialize'}->{'stash_key'} : | |
17 | $controller->{'stash_key'} | |
faf5c20b | 18 | ) || 'rest'; |
9a76221e | 19 | |
20 | if ( !$c->view($view) ) { | |
21 | $c->log->error("Could not load $view, refusing to serialize"); | |
58c1c5f5 | 22 | return; |
9a76221e | 23 | } |
24 | ||
6d4a379f | 25 | if ($c->view($view)->process($c, $stash_key)) { |
26 | return 1; | |
27 | } else { | |
28 | # This is stupid. Please improve it. | |
29 | my $error = join("\n", @{ $c->error }) || "Error in $view"; | |
30 | $error .= "\n"; | |
31 | $c->clear_errors; | |
32 | die $error; | |
33 | } | |
9a76221e | 34 | } |
35 | ||
36 | 1; |