Replace tags globaly in card text

This commit is contained in:
Adam Goldsmith 2021-09-08 20:08:36 -04:00
parent 1a9c236c01
commit 2e498dab9b

View File

@ -81,13 +81,17 @@ function leftPad(str, len, fill) {
return fill.repeat(Math.max(len - str.length, 0)) + str;
}
function replaceAll(str, search, replace) {
return str.split(search).join(replace);
}
function build_card(component) {
function substitute_tags(str) {
str = str.trim();
str = str.replace("<fullname>", String(component.getName()));
str = replaceAll(str, "<fullname>", String(component.getName()));
for (tag in tag_replacements) {
str = str.replace(tag, tag_replacements[tag]);
for (var tag in tag_replacements) {
str = replaceAll(str, tag, tag_replacements[tag]);
}
return str;
}