From f5c00fa31cd133c59ab11f646f6703a44e1d1b0d Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Sat, 1 Mar 2025 19:08:29 +0100 Subject: [PATCH] Rename "sheetsize_default" to (#380) Fixes #377 (makes HTML output template placeholders more consistent) Co-authored-by: kvid --- src/wireviz/templates/README.md | 1 + src/wireviz/templates/din-6771.html | 55 ++++++++++++++++++----------- src/wireviz/wv_output.py | 10 +++--- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/wireviz/templates/README.md b/src/wireviz/templates/README.md index 4b870c8..693ea3c 100644 --- a/src/wireviz/templates/README.md +++ b/src/wireviz/templates/README.md @@ -43,6 +43,7 @@ Note that there must be one single space between `--` and `%` at both ends. | `` | String or numeric value of `metadata.{item}` | | `` | Category number `{i}` within dict value of `metadata.{item}` | | `` | Value of `metadata.{item}.{category}.{key}` | +| `` | Value of `metadata.template.sheetsize` | Note that `{item}`, `{category}` and `{key}` in the description above can be any valid YAML key, and `{i}` is an integer representing the 1-based index of diff --git a/src/wireviz/templates/din-6771.html b/src/wireviz/templates/din-6771.html index 547a340..05f563f 100644 --- a/src/wireviz/templates/din-6771.html +++ b/src/wireviz/templates/din-6771.html @@ -1,18 +1,23 @@ + - + <!-- %title% --> +
-
+
@@ -283,4 +297,5 @@
- + + \ No newline at end of file diff --git a/src/wireviz/wv_output.py b/src/wireviz/wv_output.py index 2b587fc..0fbff9c 100644 --- a/src/wireviz/wv_output.py +++ b/src/wireviz/wv_output.py @@ -145,6 +145,9 @@ def generate_html_output( "": bom_html_reversed, "": "1", # TODO: handle multi-page documents "": "1", # TODO: handle multi-page documents + "": metadata.get("template", {}).get( + "sheetsize", "" + ), } def replacement_if_used(key: str, func: Callable[[], str]) -> None: @@ -170,11 +173,8 @@ def generate_html_output( replacements[f""] = ( html_line_breaks(str(entry_value)) ) - - replacements['"sheetsize_default"'] = '"{}"'.format( - metadata.get("template", {}).get("sheetsize", "") - ) - # include quotes so no replacement happens within