From ba156b0fec91f08af90431cdf5fccd649041d1e5 Mon Sep 17 00:00:00 2001
From: Tim Jaacks <tim.jaacks@seco.com>
Date: Fri, 13 Oct 2023 13:41:23 +0200
Subject: [PATCH] Confluence: check if variables are defined

---
 confluence-labels.txt.jinja2 | 2 ++
 confluence-page.xml.jinja2   | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/confluence-labels.txt.jinja2 b/confluence-labels.txt.jinja2
index 6c0c300d..e8d1c2ac 100644
--- a/confluence-labels.txt.jinja2
+++ b/confluence-labels.txt.jinja2
@@ -1,5 +1,7 @@
+{%- if SUPPORTED_HARDWARE is defined %}
 {%- for hardware in SUPPORTED_HARDWARE.split(',') | sort %}
 {%- if hardware | trim | length %}
 {{ hardware | trim | lower | replace(" ", "-")}}
 {%- endif %}
 {%- endfor %}
+{%- endif %}
diff --git a/confluence-page.xml.jinja2 b/confluence-page.xml.jinja2
index 46e41b0a..23274544 100644
--- a/confluence-page.xml.jinja2
+++ b/confluence-page.xml.jinja2
@@ -18,29 +18,35 @@
                 <tr>
                     <th><b>Architecture / Processor</b></th>
                     <td>
+                        {%- if MACHINE is defined %}
                         {%- for machine in MACHINE.split(' ') | sort %}
                         <p>{{ machine }}</p>
                         {%- endfor %}
+                        {%- endif %}
                     </td>
                 </tr>
                 <tr>
                     <th><b>Supported Hardware</b></th>
                     <td>
+                        {%- if SUPPORTED_HARDWARE is defined %}
                         {%- for hardware in SUPPORTED_HARDWARE.split(',') | sort %}
                         {%- if hardware | trim | length %}
                         <p>{{ hardware | trim }}</p>
                         {%- endif %}
                         {%- endfor %}
+                        {%- endif %}
                     </td>
                 </tr>
                 <tr>
                     <th><b>Documentation</b></th>
                     <td>
+                        {%- if FILES_documentation is defined %}
                         {%- for doc_file in FILES_documentation.split(' ') | sort %}
                         {%- if doc_file.endswith(".html") %}
                         <p><a href="{{ doc_file }}">{{ (doc_file | basename | splitext)[0] }}</a></p>
                         {%- endif %}
                         {%- endfor %}
+                        {%- endif %}
                     </td>
                 </tr>
             </tbody>
@@ -48,6 +54,7 @@
     </ac:rich-text-body>
 </ac:structured-macro>
 
+{%- if MACHINE is defined %}
 {%- for machine in MACHINE.split(' ') | sort %}
 <h1>{{ machine }}</h1>
 <ul>
@@ -60,3 +67,4 @@
     {%- endfor %}
 </ul>
 {%- endfor %}
+{%- endif %}
-- 
GitLab