MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / composeTemplateFile

Function composeTemplateFile

packages/shared-domain/src/template-files.ts:139–151  ·  view source on GitHub ↗
(input: ComposeTemplateInput)

Source from the content-addressed store, hash-verified

137
138/** Build a raw template `.md` (frontmatter + body) from structured fields. */
139export function composeTemplateFile(input: ComposeTemplateInput): string {
140 const lines = ['---', `name: ${yamlScalar(input.name)}`]
141 if (input.description) lines.push(`description: ${yamlScalar(input.description)}`)
142 lines.push(`category: ${input.category ?? 'Custom'}`)
143 if (input.titleTemplate) lines.push(`titleTemplate: ${yamlScalar(input.titleTemplate)}`)
144 if (input.targetFolder) lines.push(`targetFolder: ${input.targetFolder}`)
145 if (input.targetSubpath) lines.push(`targetSubpath: ${yamlScalar(input.targetSubpath)}`)
146 if (input.builtinId) lines.push(`builtinId: ${input.builtinId}`)
147 lines.push('---')
148 // One newline after the closing fence so the parser (which consumes a single
149 // trailing newline) round-trips the body without a stray leading blank line.
150 return `${lines.join('\n')}\n${input.body.replace(/^\n+/, '')}`
151}

Callers 3

store.tsFile · 0.90
editBuiltinTemplateFunction · 0.90

Calls 1

yamlScalarFunction · 0.70

Tested by

no test coverage detected