UNPKG

@itrocks/template

Version:

The W3C-valid, browser-previewable, concise, and fast HTML template engine that enables delimiter-less translations

124 lines (123 loc) 4.04 kB
import { SortedArray } from '@itrocks/sorted-array'; export type Dependencies = { toString: (value: any) => Promise<string>; }; export declare const depends: Dependencies; type BlockStackEntry = { blockStart: number; condition?: boolean; data: any; iteration: IteratorResult<any> | { done: boolean; value?: any; }; iterator?: Iterator<any>; }; type Close = ')' | '}'; type Final = '' | '-->'; type Open = '(' | '{'; export type VariableParser = [parser: string, (variable: string, data: any) => any]; export declare const frontScripts: SortedArray<string>; export declare function templateDependsOn(dependencies: Partial<Dependencies>): void; export declare class HtmlResponse { html: string; dependencies: string[]; constructor(html: string, ...dependencies: string[]); toString(): string; } export declare class Template { data?: any; containerData?: any; blockBack: number; blockStack: BlockStackEntry[]; doExpression: boolean; index: number; length: number; source: string; start: number; tagName: string; tagStack: { tagName: string; inLiteral: boolean; }[]; target: string; targetReplace: string; targetStack: string[]; doLiteral: boolean; inLiteral: boolean; literalParts: string[]; literalPartStack: string[][]; lockLiteral: boolean; addLinks: SortedArray<string>; doneLinks: SortedArray<string>; headTitle?: string; fileName?: string; filePath?: string; included: boolean; inlineElements: SortedArray<string>; literalAttributes: SortedArray<string>; literalElements: SortedArray<string>; unclosingTags: SortedArray<string>; onAttribute?: (name: string, value: string) => void; onTagOpen?: (name: string) => void; onTagOpened?: (name: string) => void; onTagClose?: (name: string) => void; parsers: VariableParser[]; prefixes: string; constructor(data?: any, containerData?: any); applyLiterals(text: string, parts?: string[]): string; closeTag(shouldInLiteral: boolean, targetIndex: number): boolean; combineLiterals(text: string, parts?: string[]): string; debugEvents(): void; embedHtmlResponse(htmlResponse: HtmlResponse): void; getCleanContext(): { addLinks: SortedArray<string>; doneLinks: SortedArray<string>; included: boolean; index: number; inLiteral: boolean; length: number; literalPartStack: never[]; literalParts: never[]; source: string; start: number; target: string; targetStack: never[]; }; getPosition(): { index: number; start: number; target: string; }; getContext(): { addLinks: SortedArray<string>; doneLinks: SortedArray<string>; included: boolean; index: number; inLiteral: boolean; length: number; literalParts: string[]; literalPartStack: string[][]; source: string; start: number; target: string; targetStack: string[]; }; include(path: string, data: any): Promise<string>; includePath(filePath: string): string; isContextClean(): boolean; literalTarget(index: number, isTitle?: boolean): void; normalizeLink(link: string): string; parseBuffer(buffer: string): Promise<string>; parseExpression(data: any, open: Open | '<', close: Close, finalClose?: Final): Promise<boolean | undefined>; parseFile(fileName: string, containerFileName?: string | false): Promise<string>; parsePath(expression: string, data: any): Promise<any>; parseVariable(variable: string, data: any): Promise<any>; parseVars(): Promise<string>; setSource(source: string, index?: number, start?: number, target?: string): void; skipBlock(): void; sourceToTarget(): void; startsExpression(char: string, open?: Open, close?: Close): boolean; trimEndLine(string: string): string; } export {};