Skip to content
Snippets Groups Projects
Commit 1d5166a8 authored by Tim Neumann's avatar Tim Neumann
Browse files

feat: Cause exception when using undefined variable

This is important to notice usage of links that do not exist
parent a014af8d
No related branches found
No related tags found
1 merge request!9Improve Error Handling again
#!/usr/bin/env python3
from typing import List, Dict, Optional, Tuple
from jinja2 import Template
from jinja2 import Template, StrictUndefined
from os import environ, path, getcwd, makedirs
from dotenv import load_dotenv
......@@ -52,7 +52,7 @@ def templatePad(file_name: str, raw_data: str, links: Dict[str, str]) -> str:
}
try:
template = Template(source=raw_data, keep_trailing_newline=True)
template = Template(source=raw_data, keep_trailing_newline=True, undefined=StrictUndefined)
return template.render(variables_for_template)
except Exception as e:
raise Exception(f"Failed to template for {file_name}.") from e
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment