From 33533407ec3cdea2014ae5c0be4ba47e93d43c89 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Sat, 27 Mar 2021 13:58:00 +0100 Subject: [PATCH] Fix template fallback logic --- src/wireviz/wv_html.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wireviz/wv_html.py b/src/wireviz/wv_html.py index 3d931bf..e4ee277 100644 --- a/src/wireviz/wv_html.py +++ b/src/wireviz/wv_html.py @@ -12,10 +12,12 @@ from wireviz.wv_gv_html import html_line_breaks def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]], metadata: Metadata, options: Options): - # fall back to built-in simple template if necessary - templatename = metadata.get('template',{}).get('name', 'simple') - # if relative path to template was provided, check directory of YAML file first, fall back to built-in template directory - templatefile = smart_file_resolve(f'{templatename}.html', [Path(filename).parent, Path(__file__).parent / 'templates']) + if 'name' in metadata.get('template',{}): + # if relative path to template was provided, check directory of YAML file first, fall back to built-in template directory + templatefile = smart_file_resolve(f'{metadata["template"]["name"]}.html', [Path(filename).parent, Path(__file__).parent / 'templates']) + else: + # fall back to built-in simple template if no template was provided + templatefile = Path(__file__).parent / 'templates/simple.html' with open(templatefile, 'r') as file: html = file.read()