From 79be720eab4c012570ce6cc47e76f9ab8daffec9 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Fri, 13 Feb 2026 03:51:37 -0700 Subject: [PATCH] Add template placeholder (port of upstream PR #492) Adds a _get_latest_revision() helper that extracts the last entry from metadata.revisions. Allows templates to show the current revision indicator without rendering the full revision table. --- src/wireviz/templates/README.md | 1 + src/wireviz/wv_output.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/wireviz/templates/README.md b/src/wireviz/templates/README.md index 693ea3c..3d08ca6 100644 --- a/src/wireviz/templates/README.md +++ b/src/wireviz/templates/README.md @@ -40,6 +40,7 @@ Note that there must be one single space between `--` and `%` at both ends. | `` | `1` (multi-page documents not yet supported) | | `` | Embedded SVG diagram as valid HTML | | `` | Embedded base64 encoded PNG diagram as URI | +| `` | The name of the last revision | | `` | String or numeric value of `metadata.{item}` | | `` | Category number `{i}` within dict value of `metadata.{item}` | | `` | Value of `metadata.{item}.{category}.{key}` | diff --git a/src/wireviz/wv_output.py b/src/wireviz/wv_output.py index 084b464..07c9b46 100644 --- a/src/wireviz/wv_output.py +++ b/src/wireviz/wv_output.py @@ -64,6 +64,12 @@ def get_mime_subtype(filename: Union[str, Path]) -> str: return mime_subtype +def _get_latest_revision(metadata: Dict) -> str: + if "revisions" not in metadata: + return "" + return list(metadata.get("revisions"))[-1] + + def embed_svg_images_file( filename_in: Union[str, Path], overwrite: bool = True ) -> None: @@ -152,6 +158,7 @@ def generate_html_output( "": metadata.get("template", {}).get( "sheetsize", "" ), + "": _get_latest_revision(metadata), } def replacement_if_used(key: str, func: Callable[[], str]) -> None: