From 6e3f340481d48d73fdb766fb8dd5bf03f740720c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= <99024746+Menrath@users.noreply.github.com> Date: Thu, 15 May 2025 10:31:52 +0200 Subject: [PATCH] fix: mustache: allow certain non body level elements as root in linter --- mustache_lint/mustache_lint.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mustache_lint/mustache_lint.php b/mustache_lint/mustache_lint.php index 3e324b65..0984f2af 100644 --- a/mustache_lint/mustache_lint.php +++ b/mustache_lint/mustache_lint.php @@ -233,11 +233,39 @@ function print_message($severity, $mesage) { echo "$FILENAME - $severity: $mesage\n"; } +/** + * If the template content has a top‐level tag that needs a container, + * wrap it in the appropriate parent before validation. + * + * @param string $content Raw HTML snippet from Mustache render. + * @return string The potentially wrapped snippet. + */ +function wrap_disallowed_root_elements($content) { + // Map of tag → [open wrapper, close wrapper]. + $wrappers = [ + 'li' => ['