UNPKG

legal-markdown-js

Version:

Node.js implementation of LegalMarkdown for processing legal documents with markdown and YAML - Complete feature parity with Ruby version

60 lines 1.93 kB
/** * Template Loop Processing Extension for Legal Markdown * * This extension adds support for template loops and conditional blocks using * the {{#variable}}...{{/variable}} syntax. It enables iteration over arrays * and conditional rendering of template sections. * * Features: * - Array iteration: {{#items}}...{{/items}} * - Conditional blocks: {{#loyaltyMember}}...{{/loyaltyMember}} * - Nested loops support * - Context management for loop variables * - Integration with field tracking * * @example * ```typescript * import { processTemplateLoops } from './template-loops'; * * const content = ` * {{#items}} * - {{name}} {{onSale ? "(ON SALE!)" : ""}} - ${{price}} * {{/items}} * `; * * const metadata = { * items: [ * { name: "Product A", price: 10.99, onSale: true }, * { name: "Product B", price: 15.50, onSale: false } * ] * }; * * const result = processTemplateLoops(content, metadata); * ``` */ /** * Interface for loop context during template processing */ export interface LoopContext { /** Current loop variable name */ variable: string; /** Current item being processed */ item: any; /** Current index in the array */ index: number; /** Total number of items */ total: number; /** Parent context for nested loops */ parent?: LoopContext; } /** * Processes template loops and conditional blocks in content * * @param content - The template content containing loop patterns * @param metadata - The metadata object containing loop data * @param context - Current loop context for nested loops * @param enableFieldTracking - Whether to enable field tracking HTML spans * @returns Processed content with loops expanded */ export declare function processTemplateLoops(content: string, metadata: Record<string, any>, context?: LoopContext, enableFieldTracking?: boolean): string; //# sourceMappingURL=template-loops.d.ts.map