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