Skip to content

Commit c94c8f2

Browse files
Store function in variable
1 parent 79c7041 commit c94c8f2

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

plugins/output/adapt/outputHelpers.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,28 +307,28 @@ function iterateThroughChildren(parents, children) {
307307
let errors = '';
308308
if (typeof parents === 'undefined') return errors;
309309

310+
const appendError = (parentType, parentTitle, childType) => {
311+
errors += app.polyglot.t('app.doesnotcontain', {
312+
type: parentType[0].toUpperCase() + parentType.slice(1),
313+
title: parentTitle,
314+
childType: childType
315+
}) + '\n';
316+
};
317+
310318
parents.forEach(parent => {
311319
let parentType = app.polyglot.t('app.' + parent._type, 1);
312320
let childType = app.polyglot.t('app.children');
313321

314322
if (typeof children === 'undefined') {
315-
errors += app.polyglot.t('app.doesnotcontain', {
316-
type: parentType[0].toUpperCase() + parentType.slice(1),
317-
title: parent.title,
318-
childType: childType
319-
}) + '\n';
323+
appendError(parentType, parent.title, childType);
320324
return;
321325
}
322326

323327
if (children[0] && children[0]._type) childType = app.polyglot.t('app.' + children[0]._type, 0);
324328
let found = children.find(child => JSON.stringify(child._parentId) === JSON.stringify(parent._id));
325329

326330
if (typeof found === 'undefined') {
327-
errors += app.polyglot.t('app.doesnotcontain', {
328-
type: parentType[0].toUpperCase() + parentType.slice(1),
329-
title: parent.title,
330-
childType: childType
331-
}) + '\n';
331+
appendError(parentType, parent.title, childType);
332332
}
333333
});
334334
return errors;

0 commit comments

Comments
 (0)