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

Function renderTemplate

packages/app-core/src/lib/template-render.ts:159–165  ·  view source on GitHub ↗
(body: string, ctx: TemplateContext)

Source from the content-addressed store, hash-verified

157
158/** Render a template body, resolving tokens and extracting the cursor offset. */
159export function renderTemplate(body: string, ctx: TemplateContext): RenderedTemplate {
160 const now = ctx.now ?? new Date()
161 const substituted = substituteTokens(body, ctx.title, now)
162 const cursorOffset = substituted.indexOf(CURSOR_TOKEN)
163 const finalBody = substituted.split(CURSOR_TOKEN).join('')
164 return { body: finalBody, cursorOffset: cursorOffset === -1 ? null : cursorOffset }
165}
166
167/** Render a title pattern (e.g. `{{date:YYYY-MM-DD}} -- `). Cursor tokens drop. */
168export function renderTitle(titleTemplate: string, ctx: TemplateContext): string {

Callers 3

store.tsFile · 0.90
TemplateEditorModalFunction · 0.90

Calls 1

substituteTokensFunction · 0.85

Tested by

no test coverage detected