| 25 | } |
| 26 | |
| 27 | childrenToString(indent, depth) { |
| 28 | const childStrings = []; |
| 29 | |
| 30 | const nextDepth = depth + 1; |
| 31 | |
| 32 | const stringChildIndents = Array(indent * nextDepth) |
| 33 | .fill('\t') |
| 34 | .join(''); |
| 35 | |
| 36 | for (const child of this.children) { |
| 37 | if (child.constructor.name === 'String') { |
| 38 | const lines = child.split('\n'); |
| 39 | |
| 40 | const indentedString = lines.map((line) => `${stringChildIndents}${line}`).join('\n'); |
| 41 | |
| 42 | childStrings.push(indentedString); |
| 43 | continue; |
| 44 | } |
| 45 | |
| 46 | const childString = child.toString(indent, nextDepth); |
| 47 | childStrings.push(childString); |
| 48 | } |
| 49 | |
| 50 | const string = childStrings.join('\n'); |
| 51 | |
| 52 | return string; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | module.exports = { Component }; |