UNPKG

@stacksjs/stx

Version:

A performant UI Framework. Powered by Bun.

25 lines 1.09 kB
import type { StxOptions } from './types'; /** * Process loops (@foreach, @for, @while, @forelse) * * Loop Configuration (via options.loops): * - maxWhileIterations: Safety limit for @while loops (default: 1000) * - useAltLoopVariable: Use $loop instead of loop (default: false) * * Loop Context Variables: * Within @foreach loops, a loop context object is available: * - loop.index: Current zero-based index * - loop.iteration: Current one-based iteration count * - loop.first: Boolean, true if first iteration * - loop.last: Boolean, true if last iteration * - loop.count: Total number of items * * If options.loops.useAltLoopVariable is true, use $loop instead of loop * to avoid conflicts with user variables named 'loop'. * * @param template - Template string to process * @param context - Template context with variables * @param filePath - Path to template file for error messages * @param options - Optional stx configuration */ export declare function processLoops(template: string, context: Record<string, any>, filePath: string, options?: StxOptions): string;