return 0 on not found

This commit is contained in:
Graham Ollis
2012-08-25 07:15:15 -04:00
parent b48b4274db
commit 51af0a7893
2 changed files with 6 additions and 1 deletions

View File

@@ -85,9 +85,12 @@ sub _render {
my $provider = $self->tt->{SERVICE}->{CONTEXT}->{LOAD_TEMPLATES}->[0];
$provider->options($options);
$provider->ctx($c);
$provider->not_found(0);
my $ok = $self->tt->process(defined $inline ? \$inline : $t, @params);
return 0 if $provider->not_found;
# Error
die $self->tt->error unless $ok;
@@ -150,6 +153,7 @@ sub new {
sub renderer { @_ > 1 ? $_[0]->{renderer} = $_[1] : $_[0]->{renderer} }
sub ctx { @_ > 1 ? $_[0]->{ctx} = $_[1] : $_[0]->{ctx} }
sub options { @_ > 1 ? $_[0]->{options} = $_[1] : $_[0]->{options} }
sub not_found { @_ > 1 ? $_[0]->{not_found} = $_[1] : $_[0]->{not_found} }
sub _template_modified {1}
@@ -173,6 +177,7 @@ sub _template_content {
# Try DATA section
if(defined $options) {
$data = $self->renderer->get_data_template($options);
$self->not_found(1) unless defined $data;
} else {
my $loader = Mojo::Loader->new;
foreach my $class (@{ $self->renderer->classes }) {

View File

@@ -28,7 +28,7 @@ my $t = Test::Mojo->new;
$t->get_ok('/')
->status_is(500)
->content_isnt('');
->content_like(qr{foo});
__DATA__