always use template strings instead of string concatenation

This commit is contained in:
zadam
2022-12-21 15:19:05 +01:00
parent ea006993f6
commit 1b24276a4a
154 changed files with 433 additions and 437 deletions

View File

@@ -6,7 +6,7 @@ async function renderAttribute(attribute, renderIsInheritable) {
const $attr = $("<span>");
if (attribute.type === 'label') {
$attr.append(document.createTextNode('#' + attribute.name + isInheritable));
$attr.append(document.createTextNode(`#${attribute.name}${isInheritable}`));
if (attribute.value) {
$attr.append('=');
@@ -19,11 +19,11 @@ async function renderAttribute(attribute, renderIsInheritable) {
// when the relation has just been created then it might not have a value
if (attribute.value) {
$attr.append(document.createTextNode('~' + attribute.name + isInheritable + "="));
$attr.append(document.createTextNode(`~${attribute.name}${isInheritable}=`));
$attr.append(await createNoteLink(attribute.value));
}
} else {
ws.logError("Unknown attr type: " + attribute.type);
ws.logError(`Unknown attr type: ${attribute.type}`);
}
return $attr;
@@ -34,16 +34,16 @@ function formatValue(val) {
return val;
}
else if (!val.includes('"')) {
return '"' + val + '"';
return `"${val}"`;
}
else if (!val.includes("'")) {
return "'" + val + "'";
return `'${val}'`;
}
else if (!val.includes("`")) {
return "`" + val + "`";
return `\`${val}\``;
}
else {
return '"' + val.replace(/"/g, '\\"') + '"';
return `"${val.replace(/"/g, '\\"')}"`;
}
}
@@ -55,7 +55,7 @@ async function createNoteLink(noteId) {
}
return $("<a>", {
href: '#root/' + noteId,
href: `#root/${noteId}`,
class: 'reference-link',
'data-note-path': noteId
})