(input: ComposeTemplateInput)
| 137 | |
| 138 | /** Build a raw template `.md` (frontmatter + body) from structured fields. */ |
| 139 | export 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 | } |
no test coverage detected