correctly substituting text for a dynamic placeholder see #527
This commit is contained in:
parent
049b88302a
commit
5e8015161b
1 changed files with 5 additions and 1 deletions
|
|
@ -395,13 +395,17 @@ export const placeholdersUtils = {
|
||||||
use_default_value = false,
|
use_default_value = false,
|
||||||
skip_additional_text = false
|
skip_additional_text = false
|
||||||
} = args || {};
|
} = args || {};
|
||||||
|
console.log(">>>>>>>>>> replacePlaceholders replacements: " + JSON.stringify(replacements));
|
||||||
// Regular expression to match patterns like {%...%}
|
// Regular expression to match patterns like {%...%}
|
||||||
return text.replace(/{%\s*(.*?)\s*%}/g, function(match, p1) {
|
return text.replace(/{%\s*(.*?)\s*%}/g, function(match, p1) {
|
||||||
|
console.log(">>>>>>>>>> replacePlaceholders match: " + JSON.stringify(match));
|
||||||
|
console.log(">>>>>>>>>> replacePlaceholders p1: " + JSON.stringify(p1));
|
||||||
// p1 contains the key inside {% %}
|
// p1 contains the key inside {% %}
|
||||||
if (skip_additional_text && (p1 === 'additional_text')) {
|
if (skip_additional_text && (p1 === 'additional_text')) {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
const currPlaceholder = defaultPlaceholders.find(ph => ph.id === p1);
|
const currPlaceholder = defaultPlaceholders.find(ph => (ph.id === p1) || (ph.is_dynamic == 1 && p1.startsWith(ph.id + ':')));
|
||||||
|
console.log(">>>>>>>>>> replacePlaceholders currPlaceholder: " + JSON.stringify(currPlaceholder));
|
||||||
if (!currPlaceholder) {
|
if (!currPlaceholder) {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue