Merge branch 'develop' into feature/CSR-76
This commit is contained in:
commit
77e8fd1d34
1 changed files with 18 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue