-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check template file exists? #44
Comments
@fangyuan you can get the file path using Dancer's So all together your route would look like this: get '/help/:subject' => {
my $subject = param 'subject';
my $tmpl = sprintf('help/%s.tt', $subject);
if ( -f config->{ 'views' }.'/'.$tmpl ) {
template $tmpl;
} else {
# Do something else instead of a 500
}
} |
@lejeunerenard, thanks for the suggestion, it is one both simple and quick solution. There is another method, check template render result. If
|
Closing as answered query. |
Hi, I have a problem that how to detect template file whether exists before render it.
In my Dancer app route service, like this:
get '/help/:subject' => { my $subject = param 'subject'; template sprintf('help/%s.tt', $subject); # will get 500 if cannot found template }
So, it could check template file exists before render it and avoid error 500. But I didnot find answer in template manual.
Any ideas? Thanks.
The text was updated successfully, but these errors were encountered: