Add support for running render without a context
[catagits/Catalyst-View-TT.git] / lib / Catalyst / View / TT.pm
index f60af73..1dcc88a 100644 (file)
@@ -228,7 +228,7 @@ sub process {
 sub render {
     my ($self, $c, $template, $args) = @_;
 
-    $c->log->debug(qq/Rendering template "$template"/) if $c->debug;
+    $c->log->debug(qq/Rendering template "$template"/) if $c && $c->debug;
 
     my $output;
     my $vars = {
@@ -250,6 +250,7 @@ sub render {
 sub template_vars {
     my ( $self, $c ) = @_;
 
+    return  () unless $c;
     my $cvar = $self->config->{CATALYST_VAR};
 
     defined $cvar
@@ -500,6 +501,9 @@ C<$template> can be anything that Template::process understands how to
 process, including the name of a template file or a reference to a test string.
 See L<Template::process|Template/process> for a full list of supported formats.
 
+To use the render method outside of your Catalyst app, just pass a undef context. 
+This can be useful for tests, for instance.
+
 =head2 template_vars
 
 Returns a list of keys/values to be used as the catalyst variables in the