if (template address exists) { include template } else { include other template } #### sub template_exists { my ($self, $file) = @_; my $path = $self->config->template_path; return 1 if grep { -e && -f && -r } map { "$_/$file" } @$path; return; } #### [% FOREACH thing = collection %] [% template = factory.template_exists("list/types/${thing.type}.html") ? "list/types/${thing.type}.html" : "list/types/default.html" %] [% INCLUDE $template %] [% END %]