The template method (part of the Kelp::Response class) already passes a reference to your application instance via the app variable. So, if you have an application method called is_logged_in, you can access it in the templates via app.is_logged_in.
If you absolutely have to have a shortcut to is_logged_in, then the best approach is to create your own Response class, which overrides the template function.
package Fan::Response;
use Kelp::Base 'Kelp::Response';
sub template {
my ( $self, $template, $vars, @rest ) = @_;
$vars->{is_logged_in} = $self->app->is_logged_in; # is_logged_in is now available in the templates
return $self->SUPER::template($template, $vars, @rest);
}
You will have to tell Kelp to use your "custom" response class instead of the default one:
my $app = Fan->new( response_obj => 'Fan::Response' );
Alternatively, you can override the
build_response method in Fan.pm as shown here:
https://metacpan.org/pod/Kelp#build_request (this example shows how to override a request, but overriding the response is just as easy)
I hope that helps.
Stefan