/** * Template Engine for Living Docs Scaffolding * * Provides variable substitution for .md.template files. * Works with ANY user project - no hardcoded paths or project names. * * Supports: * - Simple variables: ${variableName} * - Conditional blocks: ${if:condition}...${endif} (supports nesting) * - Loop blocks: ${each:items}...${endeach} (supports nesting) * - Default values: ${variableName:defaultValue} * - Nested conditionals and loops (recursive processing) * * @module core/living-docs/scaffolding/template-engine */ import { Logger } from '../../../utils/logger.js'; /** * Template variables context */ export interface TemplateContext { projectId: string; projectName: string; projectDescription?: string; createdDate: string; lastUpdatedDate: string; featureId?: string; featureTitle?: string; featureStatus?: string; featurePriority?: string; incrementId?: string; incrementsRelativePath?: string; userStories?: Array<{ id: string; title: string; fileName: string; status?: string; }>; increments?: Array<{ id: string; link: string; status: string; statusEmoji: string; date: string; }>; overview?: string; [key: string]: unknown; } /** * Default template context values */ export declare function createDefaultContext(projectId: string): TemplateContext; /** * Template Engine class * * Supports deeply nested conditionals and loops through recursive processing. */ export declare class TemplateEngine { private logger; constructor(options?: { logger?: Logger; }); /** * Render a template with the given context * * Processes nested structures by recursively rendering until no more * template syntax remains (up to MAX_RECURSION_DEPTH iterations). */ render(template: string, context: TemplateContext): string; /** * Process conditional blocks with proper nesting support * * Uses a non-greedy innermost-first approach to handle nesting: * ${if:outer}${if:inner}...${endif}${endif} */ private processConditionals; /** * Process loop blocks with proper nesting support * * Uses a non-greedy innermost-first approach to handle nesting: * ${each:outer}${each:inner}...${endeach}${endeach} */ private processLoops; /** * Check if a value is truthy for template conditionals */ private isTruthy; /** * Get a nested value from an object using dot notation * Supports: item.user.name, item.tags.0, etc. */ private getNestedValue; private processVariables; private getContextValue; /** * Validate template syntax for common errors * * Checks for: * - Mismatched if/endif blocks * - Mismatched each/endeach blocks * - Detects potential infinite loops (self-referencing) */ validateTemplate(template: string): string[]; } export declare function getTemplateEngine(options?: { logger?: Logger; }): TemplateEngine; export declare function renderTemplate(template: string, context: TemplateContext): string; //# sourceMappingURL=template-engine.d.ts.map