/** * TemplateRenderer - Utility class for rendering templates with comprehensive validation * * IMPROVEMENTS IMPLEMENTED (per Debug Detective recommendations): * 1. instanceof Template verification for type safety * 2. Performance logging to track render times * 3. Validation of render() return value * 4. Clear separation of concerns from index.ts * * This addresses Issues #913 and #914 from the v1.7.3 hotfix */ import { TemplateManager } from '../elements/templates/TemplateManager.js'; export interface RenderResult { success: boolean; content?: string; /** Populated when all_sections: true — rendered template + raw style/script */ sections?: { template: string; style: string; script: string; }; error?: string; /** Unsubstituted {{placeholder}} names found in the rendered output (#1896) */ warnings?: string[]; performance?: { lookupTime: number; renderTime: number; totalTime: number; }; } /** Options for section-format template rendering (issue #705) */ export interface RenderOptions { /** Extract a specific raw section: 'style' or 'script' (no variable substitution). */ section?: 'template' | 'style' | 'script'; /** Return all sections: { template: rendered, style: raw, script: raw }. */ allSections?: boolean; } export declare class TemplateRenderer { private templateManager; constructor(templateManager: TemplateManager); /** * Render a template with comprehensive validation and performance tracking * * VALIDATION CHAIN: * 1. Unicode normalization of template name * 2. Template exists in manager * 3. Template is proper Template instance * 4. Template has render() method * 5. render() returns a string * * SECURITY: * - Unicode normalization prevents homograph attacks * - Variables are normalized by Template.render() internally * * PERFORMANCE TRACKING: * - Lookup time (finding template) * - Render time (actual rendering) * - Total time (complete operation) */ render(name: string, variables?: Record, section?: 'template' | 'style' | 'script', allSections?: boolean): Promise; /** * Scan rendered output for any remaining {{placeholder}} patterns and * return an advisory warnings array (or undefined if everything was filled). * Extracted from render() to keep its cognitive complexity within limits. * (#1896) */ private detectUnsubstituted; /** * Batch render multiple templates (useful for testing) * SECURITY: Each template name is normalized individually */ renderBatch(templates: Array<{ name: string; variables: Record; }>): Promise>; /** * Validate that a template can be rendered without actually rendering it * SECURITY: Template name is normalized to prevent Unicode attacks */ validate(name: string): Promise<{ valid: boolean; reason?: string; }>; } //# sourceMappingURL=TemplateRenderer.d.ts.map