From 1d6ce2ebb1e6e99c3d9798c3fe4e5a96aea62951 Mon Sep 17 00:00:00 2001
From: eliott <eliott.sammier@tetras-libre.fr>
Date: Wed, 31 Jul 2024 17:14:31 +0200
Subject: [PATCH] Template st:module now better supports unbound variables

---
 tetras_extraction/script/templates/module.rq | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tetras_extraction/script/templates/module.rq b/tetras_extraction/script/templates/module.rq
index 86be805d..e2a3c458 100644
--- a/tetras_extraction/script/templates/module.rq
+++ b/tetras_extraction/script/templates/module.rq
@@ -9,8 +9,7 @@ template mt:module(?mod) {
     format {
         """+++
 title = "%s"
-weight = %s0
-bookCollapseSection = true
+%sbookCollapseSection = true
 +++
 
 # %1$s
@@ -21,7 +20,7 @@ bookCollapseSection = true
         # (not explicitly documented but confirmed from testing), including
         # "%1$" position specifiers, which allows reusing the 1st param by index
         ?title
-        ?weight
+        coalesce(st:format("weight = %s\n", ?weight * 10), "")
     } st:nl()
 
     group {
@@ -42,6 +41,8 @@ bookCollapseSection = true
 
     # Module / section attributes
     ?mod :titre ?title .
-    ?mod :index ?index .
-    bind(?index + 1 as ?weight)
+    optional {
+        ?mod :index ?index .
+        bind(?index + 1 as ?weight)
+    }
 }
-- 
GitLab