1 |
|
2 |
|
3 | export declare class Swig {
|
4 | constructor(options?: SwigOptions);
|
5 |
|
6 | setFilter(
|
7 | name: string,
|
8 | method: (input: any, ...args: any[]) => string,
|
9 | ): void;
|
10 | setTag(
|
11 | name: string,
|
12 | parse: (
|
13 | str?: string,
|
14 | line?: string,
|
15 | parser?: Object,
|
16 | types?: lexer.TYPES,
|
17 | stack?: any,
|
18 | opts?: Object,
|
19 | swig?: Swig,
|
20 | ) => boolean,
|
21 | compile: (
|
22 | compiler?: (content?: string, parents?: any, options?: any, blockName?: string) => string,
|
23 | args?: any[],
|
24 | content?: string,
|
25 | parents?: any,
|
26 | options?: any,
|
27 | blockName?: string,
|
28 | ) => string,
|
29 | ends?: boolean,
|
30 | blockLevel?: boolean,
|
31 | ): void;
|
32 | setExtension(name: string, object: any): void;
|
33 | parseFile(pathName: string, options?: any): parser.ParseReturn;
|
34 | precompile(source: string, options?: SwigOptions): any;
|
35 | compile(source: string, options?: SwigOptions): (locals?: any) => string;
|
36 | compileFile(
|
37 | pathname: string,
|
38 | options: SwigOptions,
|
39 | cb: (err: Error, compiledRender: (locals?: any) => string) => void,
|
40 | ): void;
|
41 | compileFile(pathname: string, options?: SwigOptions): (locals?: any) => string;
|
42 | render(source: string, options?: SwigOptions): string;
|
43 | renderFile(pathName: string, locals: any, cb: (err: Error, output: string) => void): void;
|
44 | renderFile(pathName: string, locals?: any): string;
|
45 | run(templateFn: Function, locals?: any, filePath?: string): string;
|
46 | invalidateCache(): void;
|
47 |
|
48 | loaders: typeof loaders;
|
49 | }
|
50 |
|
51 | export declare namespace lexer {
|
52 | export enum TYPES {
|
53 |
|
54 | WHITESPACE = 0,
|
55 |
|
56 | STRING = 1,
|
57 |
|
58 | FILTER = 2,
|
59 |
|
60 | FILTEREMPTY = 3,
|
61 |
|
62 | FUNCTION = 4,
|
63 |
|
64 | FUNCTIONEMPTY = 5,
|
65 |
|
66 | PARENOPEN = 6,
|
67 |
|
68 | PARENCLOSE = 7,
|
69 |
|
70 | COMMA = 8,
|
71 |
|
72 | VAR = 9,
|
73 |
|
74 | NUMBER = 10,
|
75 |
|
76 | OPERATOR = 11,
|
77 |
|
78 | BRACKETOPEN = 12,
|
79 |
|
80 | BRACKETCLOSE = 13,
|
81 |
|
82 | DOTKEY = 14,
|
83 |
|
84 | ARRAYOPEN = 15,
|
85 | |
86 |
|
87 |
|
88 |
|
89 | CURLYOPEN = 17,
|
90 |
|
91 | CURLYCLOSE = 18,
|
92 |
|
93 | COLON = 19,
|
94 |
|
95 | COMPARATOR = 20,
|
96 |
|
97 | LOGIC = 21,
|
98 |
|
99 | NOT = 22,
|
100 |
|
101 | BOOL = 23,
|
102 |
|
103 | ASSIGNMENT = 24,
|
104 |
|
105 | METHODOPEN = 25,
|
106 | |
107 |
|
108 |
|
109 |
|
110 | UNKNOWN = 100,
|
111 | }
|
112 |
|
113 | export function read(str: string): string[];
|
114 | }
|
115 |
|
116 | export declare namespace parser {
|
117 | interface ParseReturn {
|
118 | name: string;
|
119 | parent: any;
|
120 | tokens: any[];
|
121 | blocks: any;
|
122 | }
|
123 | }
|
124 |
|
125 | export interface SwigOptions {
|
126 | autoescape?: boolean | undefined;
|
127 | cache?: any;
|
128 | cmtControls?: string[] | undefined;
|
129 | loader?: TemplateLoader | undefined;
|
130 | locals?: any;
|
131 | tagControls?: string[] | undefined;
|
132 | varControls?: string[] | undefined;
|
133 | }
|
134 |
|
135 | export interface TemplateLoader {
|
136 | resolve(to: string, from: string): string;
|
137 | load(identifier: string, callback?: (err: Error, data: any) => void): void;
|
138 | load(identifier: string): any;
|
139 | }
|
140 |
|
141 | export declare namespace loaders {
|
142 | export function fs(basepath?: string, encoding?: string): TemplateLoader;
|
143 | export function memory(mapping: any, basepath?: string): TemplateLoader;
|
144 | }
|
145 |
|
146 | export declare var version: string;
|
147 | export declare function setDefaults(options: SwigOptions): void;
|
148 | export declare function setDefaultTZOffset(offset: number): void;
|
149 | export declare function setFilter(
|
150 | name: string,
|
151 | method: (input: any, ...args: any[]) => string,
|
152 | ): void;
|
153 | export declare function setTag(
|
154 | name: string,
|
155 | parse: (
|
156 | str?: string,
|
157 | line?: string,
|
158 | parser?: Object,
|
159 | types?: lexer.TYPES,
|
160 | stack?: any,
|
161 | opts?: Object,
|
162 | swig?: Swig,
|
163 | ) => boolean,
|
164 | compile: (
|
165 | compiler?: (content?: string, parents?: any, options?: any, blockName?: string) => string,
|
166 | args?: any[],
|
167 | content?: string,
|
168 | parents?: any,
|
169 | options?: any,
|
170 | blockName?: string,
|
171 | ) => string,
|
172 | ends?: boolean,
|
173 | blockLevel?: boolean,
|
174 | ): void;
|
175 | export declare function setExtension(name: string, object: any): void;
|
176 | export declare function parseFile(pathName: string, options?: any): parser.ParseReturn;
|
177 | export declare function precompile(source: string, options?: SwigOptions): any;
|
178 | export declare function compile(source: string, options?: SwigOptions): (locals?: any) => string;
|
179 | export declare function compileFile(
|
180 | pathname: string,
|
181 | options: SwigOptions,
|
182 | cb: (err: Error, compiledRender: (locals?: any) => string) => void,
|
183 | ): void;
|
184 | export declare function compileFile(pathname: string, options?: SwigOptions): (locals?: any) => string;
|
185 | export declare function render(source: string, options?: SwigOptions): string;
|
186 | export declare function renderFile(pathName: string, locals: any, cb: (err: Error, output: string) => void): void;
|
187 | export declare function renderFile(pathName: string, locals?: any): string;
|
188 | export declare function run(templateFn: Function, locals?: any, filePath?: string): string;
|
189 | export declare function invalidateCache(): void;
|