| 1 | package JiftyX::Markapl::Handler; | ||
| 2 | use strict; | ||
| 3 | use parent qw/Jifty::View/; | ||
| 4 | |||
| 5 | sub new { | ||
| 6 | my $class = shift; | ||
| 7 | my $self = {}; | ||
| 8 | bless $self,$class; | ||
| 9 | my $template_class = Jifty->config->framework("TemplateClass"); | ||
| 10 | |||
| 11 | Jifty->handler->buffer( Markapl->buffer ); | ||
| 12 | { | ||
| 13 | my $buffer = Jifty->handler->buffer; | ||
| 14 | no warnings 'redefine'; | ||
| 15 | *Jifty::Web::out = sub {shift;unshift @_,$buffer;goto \&String::BufferStack::append}; | ||
| 16 | } | ||
| 17 | |||
| 18 | return $self; | ||
| 19 | } | ||
| 20 | |||
| 21 | sub show { | ||
| 22 | my $self = shift; | ||
| 23 | my $template = shift; | ||
| 24 | my $template_class = Jifty->config->framework("TemplateClass"); | ||
| 25 | |||
| 26 | $template_class->render($template); | ||
| 27 | Jifty->handler->buffer->clear; | ||
| 28 | return ''; | ||
| 29 | } | ||
| 30 | |||
| 31 | sub template_exists { | ||
| 32 | my $pkg = shift; | ||
| 33 | my $template = shift; | ||
| 34 | my $template_class = Jifty->config->framework("TemplateClass"); | ||
| 35 | if ($template_class->can($template)) { | ||
| 36 | return $template; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | 1; |