diff --git a/lib/util/yaml.spec.ts b/lib/util/yaml.spec.ts
index b09331b7d3474b9018db13929d61e0fc712dffc5..68b339937c09a59bc8d7891b7ca4d355bd218078 100644
--- a/lib/util/yaml.spec.ts
+++ b/lib/util/yaml.spec.ts
@@ -102,12 +102,19 @@ describe('util/yaml', () => {
           codeBlock`
       myObject:
         aString: {{value}}
+        {% if test.enabled %}
+        myNestedObject:
+          aNestedString: {{value}}
+        {% endif %}
       `,
           { removeTemplates: true },
         ),
       ).toEqual({
         myObject: {
           aString: null,
+          myNestedObject: {
+            aNestedString: null,
+          },
         },
       });
     });
diff --git a/lib/util/yaml.ts b/lib/util/yaml.ts
index 8921803f2975ba76dbb4c6f1824f084b91e66cf5..b8c2847fdf72475da6ab265b396103702da7693e 100644
--- a/lib/util/yaml.ts
+++ b/lib/util/yaml.ts
@@ -37,7 +37,9 @@ function massageContent(content: string, options?: YamlOptions): string {
   if (options?.removeTemplates) {
     return content
       .replace(regEx(/{{`.+?`}}/gs), '')
-      .replace(regEx(/{{.+?}}/g), '');
+      .replace(regEx(/{{.+?}}/g), '')
+      .replace(regEx(/{%`.+?`%}/gs), '')
+      .replace(regEx(/{%.+?%}/g), '');
   }
 
   return content;