hasPlaceholder and replacePlaceholder can now work with dynamic placeholders. see #525 #554

This commit is contained in:
mic 2026-02-10 21:42:26 +01:00
parent 2740fe3ee9
commit 34e8e242f6

View file

@ -436,7 +436,7 @@ export const placeholdersUtils = {
return match;
}
// Replace if found, otherwise keep the original or substitute with default value
return replacements[p1] || (use_default_value ? currPlaceholder.default_value : match);
return replacements[p1] || replacements[currPlaceholder.id] || (use_default_value ? currPlaceholder.default_value : match);
});
},
@ -459,7 +459,7 @@ export const placeholdersUtils = {
// If a specific placeholder is provided, we search for it
if (placeholder !== "") {
// Dynamically build the regex for the specific placeholder
regex = new RegExp(`{%\s*${placeholder}\s*%}`);
regex = new RegExp(`{%\s*${placeholder}(:.*?)?\s*%}`);
} else {
// Otherwise, we search for any placeholder in the format {% ... %}
regex = /{%\s*(.*?)\s*%}/;