Closed bryanburgers closed 6 years ago
@carllerche OK, I decided to panic if either TOWER_WEB_TEMPLATE_DIR
or ${TOWER_WEB_TEMPLATE_DIR}/templates
does not exist.
I'm still a little bit torn if we should require the templates
sub-directory or not.
Add locations to look for a templates directory when using
view::Handlebars::new()
.Previously, this would only look at the environment variable
CARGO_MANIFEST_DIR
, which is only set when run usingcargo
. This makes it hard to deploy an application that uses handlebars templates.This change introduces a chain of places to check for a templates directory.
templates
directory under theTOWER_WEB_TEMPLATE_DIR
environment variabletemplates
directory under the crate root (CARGO_MANIFEST_DIR
environment variable)templates
directory under the current working directory.This commit also adds an improved error message when one of these locations does not exist when the handlebars location is registered. This is a small breaking change because previously an application would not
panic!
if thetemplates
directory did not exist on application startup.Fixes #127 and #136