MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / renderTemplate

Function renderTemplate

src/cli/custom-commands.ts:205–214  ·  view source on GitHub ↗
(template: string, args: string, ctx: { cwd: string })

Source from the content-addressed store, hash-verified

203
204/** Interpolate the template body with the user-supplied args + builtin tokens. */
205export function renderTemplate(template: string, args: string, ctx: { cwd: string }): string {
206 const positionals = args.length > 0 ? args.split(/\s+/).filter(Boolean) : [];
207 const now = new Date();
208 return template
209 .replace(/\{\{\s*ARGUMENTS\s*\}\}/g, args)
210 .replace(/\{\{\s*ARG:(\d+)\s*\}\}/g, (_, idx) => positionals[parseInt(idx, 10)] ?? '')
211 .replace(/\{\{\s*CWD\s*\}\}/g, ctx.cwd)
212 .replace(/\{\{\s*DATE\s*\}\}/g, now.toISOString().slice(0, 10))
213 .replace(/\{\{\s*TIME\s*\}\}/g, now.toTimeString().slice(0, 8));
214}

Callers 2

handleSlashCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected