| 17505 | return this |
| 17506 | } |
| 17507 | templateToString(obj) { |
| 17508 | // todo: compile/cache for perf? |
| 17509 | const particle = this.clone() |
| 17510 | particle.topDownArray.forEach(particle => { |
| 17511 | const line = particle.getLine().replace(/{([^\}]+)}/g, (match, path) => { |
| 17512 | const replacement = obj[path] |
| 17513 | if (replacement === undefined) throw new Error(`In string template no match found on line "${particle.getLine()}"`) |
| 17514 | return replacement |
| 17515 | }) |
| 17516 | particle.pasteText(line) |
| 17517 | }) |
| 17518 | return particle.toString() |
| 17519 | } |
| 17520 | shiftRight() { |
| 17521 | const olderSibling = this._getClosestOlderSibling() |
| 17522 | if (!olderSibling) return this |