Merge branch 'develop' into feature/CSR-76

This commit is contained in:
Max 2021-12-17 15:58:37 -05:00
commit 77e8fd1d34

View file

@ -30,23 +30,31 @@ export function fetchCmsContentForPage(fmgPage) {
// Function to convert a string, into a matching global state item.
function mapStringToState(str) {
// Pull the state string out of our dynamic string from the CMS
// Pull all matches out of the string.
const regexExp = new RegExp('{(.*?):(.*?)}', 'g');
const matches = [...str.matchAll(regexExp)];
const stateString = matches.map(m => m[2]).toString();
// Convert the state string to a state object
let storeState = store.state;
// Our final string value that will be built from the matches.
let stringBuilder = '';
for (const s of stateString.split('.')) {
if (storeState[s] != undefined) {
storeState = storeState[s];
} else {
return false; // If we can't find our state variable, break our loop. Don't break our code.
for (const match of matches) {
// Reset store state for each match.
let storeState = store.state;
for (const s of match[2].split('.')) {
if (storeState[s] != undefined) {
storeState = storeState[s];
} else {
return false;
}
}
// Concatenate the string.
stringBuilder = `${stringBuilder} ${storeState}`;
}
return storeState;
return stringBuilder.trimStart();
}
// Parent function for processWidgetItemForReplacement. This will loop through the parent