| 1 | package Web::App::Presenter::AsIs; | ||
| 2 | |||
| 3 | use Class::Easy; | ||
| 4 | |||
| 5 | use base qw(Web::App::Presenter); | ||
| 6 | |||
| 7 | sub headers { | ||
| 8 | my $app = Web::App->app; | ||
| 9 | my $headers = $app->response->headers; | ||
| 10 | $headers->header ('Cache-Control' => 'no-store'); | ||
| 11 | } | ||
| 12 | |||
| 13 | # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
| 14 | sub process { | ||
| 15 | my $self = shift; | ||
| 16 | my $app = shift; | ||
| 17 | my $data = shift; | ||
| 18 | my %params = @_; | ||
| 19 | |||
| 20 | critical "can't use whole stash, please use var parameter" | ||
| 21 | unless $params{var}; | ||
| 22 | |||
| 23 | if ($params{content_type}) { | ||
| 24 | my $headers = $app->response->headers; | ||
| 25 | $headers->header ('Content-Type' => $params{content_type}); | ||
| 26 | } else { | ||
| 27 | critical "you must define content_type parameter for this presenter"; | ||
| 28 | } | ||
| 29 | |||
| 30 | return $data->{$params{var}}; | ||
| 31 | } | ||
| 32 | # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
| 33 | # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
| 34 | # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
| 35 | |||
| 36 | sub wrap_log { | ||
| 37 | my $self = shift; | ||
| 38 | my $content = shift; | ||
| 39 | |||
| 40 | return join '', "\n<!--\n", $content, "\n-->\n"; | ||
| 41 | } | ||
| 42 | |||
| 43 | |||
| 44 | 1; | ||
| 45 |