@@ -97,6 +97,8 @@ export function convertArabicToRoman(num) {
9797/**
9898 * Render name template based on config.
9999 * Use substitution map to replace a config value with a more readable variant.
100+ * NOTE: We currently iterate through the whole object. A more efficient albeit more verbose approach would be
101+ * to give the property path in the subsitution map, e.g., `{ "user.name": {"user001": "John Doe"} }`.
100102 * @param {string|undefined } template - Template for the name property
101103 * @param {Object } data - Entity config
102104 * @param {Object } substitutionMap - Maps object value to human-readable string
@@ -115,13 +117,19 @@ export function renderTextWithSubstitutes(template, data, substitutionMap = {})
115117
116118 // Helper function for recursive substitution
117119 function substituteNested ( obj ) {
118- lodash . forIn ( obj , ( value , key ) => {
120+ if ( ! lodash . isPlainObject ( obj ) ) {
121+ return ;
122+ }
123+ // eslint-disable-next-line no-restricted-syntax
124+ for ( const [ key , value ] of Object . entries ( obj ) ) {
119125 if ( lodash . isPlainObject ( value ) ) {
120126 substituteNested ( value ) ;
127+ } else if ( Array . isArray ( value ) ) {
128+ value . forEach ( ( val ) => substituteNested ( val ) ) ;
121129 } else if ( substitutionMap [ value ] ) {
122130 obj [ key ] = substitutionMap [ value ] ;
123131 }
124- } ) ;
132+ }
125133 }
126134
127135 substituteNested ( renderData ) ;
0 commit comments