Fail more gracefully when parsing templates