- Expand TTSite documentation (RT #33838)
- Added a test for direct rendering of a template from a view object,
without a request.
+ - Added support for running render with a undef context.
0.29 2009-02-20 14:43:00
- Remove extra unwanted .gitignore from manifest
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 = {
sub template_vars {
my ( $self, $c ) = @_;
+ return () unless $c;
my $cvar = $self->config->{CATALYST_VAR};
defined $cvar
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
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More tests => 3;
use FindBin;
use lib "$FindBin::Bin/lib";
BEGIN { use_ok 'TestApp' or die }
-ok my $c = TestApp->new, 'Instantiate app object';
-ok my $tt = $c->view('TT'), 'Get TT view object';
-is $tt->render($c, 'test.tt', { message => 'hello' }), 'hello',
+ok my $tt = TestApp->view('TT'), 'Get TT view object';
+is $tt->render(undef, 'test.tt', { message => 'hello' }), 'hello',
'render() should return the template output';