1+ /**
2+ * Template compilation options
3+ */
4+ export interface CompileOptions {
5+ /** Block name to compile specific block */
6+ block ?: string ;
7+ /** Enable/disable caching */
8+ cache ?: boolean ;
9+ /** Cache directory name */
10+ cacheName ?: string ;
11+ }
12+
13+ /**
14+ * Template data object - can be any object type
15+ */
16+ export type TemplateData = Record < string , any > ;
17+
18+ /**
19+ * Compiled template function
20+ */
21+ export interface CompiledTemplate {
22+ ( data ?: TemplateData , subTemplate ?: string ) : string ;
23+ }
24+
25+ /**
26+ * Template rendering callback
27+ */
28+ export interface RenderCallback {
29+ ( error : Error | null , result ?: string ) : void ;
30+ }
31+
32+ /**
33+ * Template compilation callback
34+ */
35+ export interface CompileCallback {
36+ ( error : Error | null , templateFunction ?: CompiledTemplate ) : void ;
37+ }
38+
39+ /**
40+ * Main template engine interface
41+ */
42+ export interface CBTemplate {
43+ /** Template engine version */
44+ version : string ;
45+
46+ /** Left delimiter for template syntax */
47+ leftDelimiter : string ;
48+
49+ /** Right delimiter for template syntax */
50+ rightDelimiter : string ;
51+
52+ /** Default HTML escaping setting */
53+ escape : boolean ;
54+
55+ /** Base path for template files */
56+ basePath : string ;
57+
58+ /** Cache path for compiled templates */
59+ cachePath : string ;
60+
61+ /** Default file extension */
62+ defaultExtName : string ;
63+
64+ /**
65+ * Compile template string to function
66+ * @param str Template string
67+ * @returns Compiled template function
68+ */
69+ compile ( str : string ) : CompiledTemplate ;
70+
71+ /**
72+ * Render template string with data
73+ * @param str Template string
74+ * @param data Template data
75+ * @param subTemplate Sub template name
76+ * @returns Rendered string
77+ */
78+ render ( str : string , data ?: TemplateData , subTemplate ?: string ) : string ;
79+
80+ /**
81+ * Compile template file with inheritance support
82+ * @param filename Template file path
83+ * @param options Compilation options
84+ * @param callback Compilation callback
85+ */
86+ compileFile ( filename : string , options : CompileOptions , callback : CompileCallback ) : void ;
87+ compileFile ( filename : string , callback : CompileCallback ) : void ;
88+
89+ /**
90+ * Render template file with data and inheritance support
91+ * @param filename Template file path
92+ * @param data Template data
93+ * @param options Render options
94+ * @param callback Render callback
95+ */
96+ renderFile ( filename : string , data : TemplateData , options : CompileOptions , callback : RenderCallback ) : void ;
97+ renderFile ( filename : string , data : TemplateData , callback : RenderCallback ) : void ;
98+
99+ /**
100+ * Get new instance of template engine
101+ * @returns New template engine instance
102+ */
103+ getInstance ( ) : CBTemplate ;
104+
105+ /** Internal parse method */
106+ _parse ( str : string ) : string ;
107+
108+ /** Internal build template function method */
109+ _buildTemplateFunction ( str : string ) : CompiledTemplate ;
110+ }
111+
112+ /**
113+ * Template engine instance with static methods
114+ */
115+ export interface CBTemplateStatic extends CBTemplate {
116+ /**
117+ * Get new instance of template engine
118+ * @returns New template engine instance
119+ */
120+ getInstance ( ) : CBTemplate ;
121+ }
122+
123+ declare const cbTemplate : CBTemplateStatic ;
124+ export default cbTemplate ;
0 commit comments