Skip to content

Commit

Permalink
Support plain strings in render by skipping form layer oddities that …
Browse files Browse the repository at this point in the history
…are accidentally sent in
  • Loading branch information
signalpoint committed Aug 24, 2022
1 parent 426aa40 commit 3e75bc8
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/includes/render.inc.js
Expand Up @@ -173,7 +173,12 @@ dg.appRender = function(content) {
};

dg.renderProperties = function() {
return ['_prefix', '_suffix', '_preRender', '_postRender']
return [
'_prefix',
'_suffix',
'_preRender',
'_postRender'
];
};

/**
Expand Down Expand Up @@ -275,8 +280,30 @@ dg.render = function(content, runPostRender) {
html += dg.render(piece[i]);
}
}
// @TODO this allows string to be embedded in render elements, but it breaks forms.
//else if (_type === 'string') { html += piece; }
else if (_type === 'string') {

// The content is a plain string, however the Forms layer accidentally sends in objects and arrays
// that get picked up here and printed out. We work around that here by skipping the accidental
// objects and arrays.
// TODO delve into the Forms layer and stop accidentally sending objects and arrays that aren't part of
// the render process!
if (
type === 'object' &&
(content.role && content.role === 'form') || // skip forms
index === '_action' || // skip form action
piece === '' // skip empty pieces
) { continue; }
else {
var constructorName = content.constructor.name;
if (constructorName && constructorName !== 'Array') {
weight = 0;
if (dg.isUndefined(weighted[weight])) { weighted[weight] = []; }
weighted[0].push(piece);
weightedCount++;
}
}

}
}
if (weightedCount) {
for (weight in weighted) {
Expand Down

0 comments on commit 3e75bc8

Please sign in to comment.