alapa
Version:
A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.
31 lines (30 loc) • 1.4 kB
TypeScript
/**
* An abstract class that defines a template rendering and compilation interface.
*
* Implementations of this class should provide specific logic for rendering
* templates and compiling source code into strings.
*/
export declare abstract class TemplateEngine {
protected abstract extension: string;
/**
* Renders a template with the provided data.
*
* @param template - The path to the file to read throw error if file now found.
* @param data - Optional data to be used for rendering the template. The
* shape of this data depends on the specific implementation
* and the template being used.
* @returns The rendered string resulting from applying the data to the template.
*/
render(template: string, data?: object): Promise<string>;
/**
* Compiles source code into a string representation.
*
* @param source - A string representing the source code to be compiled.
* @param data - Optional data that may be used during the compilation
* process. The specific use of this data depends on the
* implementation and the source code being compiled.
* @returns The compiled string resulting from processing the source code.
*/
abstract compile(source: string, data?: object): string;
readFileToString(filePath: string): Promise<string>;
}