fix(templating) placekeeper variable detection

This commit is contained in:
Benjamin Wegener
2024-02-03 01:07:32 +00:00
parent 925c4e7df6
commit 218af7916d

View File

@@ -38,9 +38,6 @@ export default class Placekeeper {
);
sections.push(new Map(currentSection));
currentSection.clear();
for (const [key, value] of sectionVars) {
variables.set(key, value);
}
idx++;
}
}
@@ -53,6 +50,8 @@ export default class Placekeeper {
};
}
static variableRegex = new RegExp(/[\w\d]/, 'i');
static parseVariables(content) {
// iterates over the content character by character to extract variables and returns a list of them
const variables = new Map();
@@ -60,8 +59,8 @@ export default class Placekeeper {
for (let idx = 0; idx < content.length; idx++) {
const char = content[idx];
if (char.matches(/[\w\d]/)) {
if (!currentVar instanceof Map)
if (Placekeeper.variableRegex.test(char)) {
if (!(currentVar instanceof Map))
currentVar = new Map([
['name', ''],
['start', idx],