MCPcopy Create free account
hub / github.com/breck7/scroll / templateToString

Method templateToString

external/.scrollLibs.js:17507–17519  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

cloneMethod · 0.95
forEachMethod · 0.80
replaceMethod · 0.80
pasteTextMethod · 0.80
getLineMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected