its-compiler-js
Version:
JavaScript/TypeScript implementation of the Instruction Template Specification (ITS) compiler
48 lines (47 loc) • 1.39 kB
TypeScript
/**
* Variable processing and substitution for ITS Compiler
*/
import { ContentElement } from './types.js';
export declare class VariableProcessor {
private static VARIABLE_PATTERN;
/**
* Process variable references in content elements
*/
processContent(content: ContentElement[], variables: Record<string, any>): ContentElement[];
/**
* Process variables in a single content element
*/
private processElement;
/**
* Process variables in an object
*/
private processObject;
/**
* Process variable references in a string
*/
private processString;
/**
* Resolve a variable reference like "user.name" or "items[0]"
*/
resolveVariableReference(varRef: string, variables: Record<string, any>): any;
/**
* Validate variable reference syntax
*/
private isValidVariableReference;
/**
* Parse variable reference into parts
*/
private parseVariableReference;
/**
* Sanitise resolved variable value for safe output
*/
private sanitiseResolvedValue;
/**
* Find all variable references in content
*/
findVariableReferences(content: ContentElement[]): string[];
/**
* Validate that all variable references can be resolved
*/
validateVariables(content: ContentElement[], variables: Record<string, any>): string[];
}