refactor: Harden template rendering against formatter interference

This commit is contained in:
Matteo Cherubini 2026-06-09 12:19:31 +02:00
parent afe7a7c815
commit 8fd860af5b

View file

@ -16,6 +16,12 @@ render_template() {
local content
content=$(<"$template_file")
# HARDENING: collapse any “spaced” placeholders from a formatter
# { { KEY } } -> {{KEY}} (KEY = UPPERCASE/underscore)
# Defense in depth: if Prettier or a copy-paste breaks the syntax again,
# the scaffold fixes itself. sed is a core utility (like tr/date already used here).
content=$(sed -E 's/\{[[:space:]]*\{[[:space:]]*([A-Z_]+)[[:space:]]*\}[[:space:]]*\}/{{\1}}/g' <<<"$content")
# Defaults (:-) so master-repo templates render even when GENOME_* are unset
# (scaffold_master runs before any genome; set -u would otherwise abort here).
local genome_name_upper