@samuelbines/nunjucks 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +26 -0
- package/README.md +55 -0
- package/dist/scripts/smoke.d.ts +1 -0
- package/dist/scripts/smoke.js +95 -0
- package/dist/src/compiler.d.ts +12 -0
- package/dist/src/compiler.js +1050 -0
- package/dist/src/environment.d.ts +103 -0
- package/dist/src/environment.js +621 -0
- package/dist/src/express-app.d.ts +2 -0
- package/dist/src/express-app.js +33 -0
- package/dist/src/filters.d.ts +44 -0
- package/dist/src/filters.js +424 -0
- package/dist/src/globals.d.ts +14 -0
- package/dist/src/globals.js +342 -0
- package/dist/src/index.d.ts +28 -0
- package/dist/src/index.js +116 -0
- package/dist/src/interpreter.d.ts +16 -0
- package/dist/src/interpreter.js +489 -0
- package/dist/src/lexer.d.ts +72 -0
- package/dist/src/lexer.js +480 -0
- package/dist/src/lib.d.ts +74 -0
- package/dist/src/lib.js +237 -0
- package/dist/src/loader.d.ts +80 -0
- package/dist/src/loader.js +175 -0
- package/dist/src/nodes.d.ts +362 -0
- package/dist/src/nodes.js +894 -0
- package/dist/src/parser.d.ts +66 -0
- package/dist/src/parser.js +1068 -0
- package/dist/src/precompile.d.ts +15 -0
- package/dist/src/precompile.js +108 -0
- package/dist/src/runtime.d.ts +33 -0
- package/dist/src/runtime.js +314 -0
- package/dist/src/transformer.d.ts +3 -0
- package/dist/src/transformer.js +161 -0
- package/dist/src/types.d.ts +27 -0
- package/dist/src/types.js +2 -0
- package/dist/tests/compiler.test.d.ts +1 -0
- package/dist/tests/compiler.test.js +201 -0
- package/dist/tests/enviornment.test.d.ts +1 -0
- package/dist/tests/enviornment.test.js +279 -0
- package/dist/tests/express.test.d.ts +1 -0
- package/dist/tests/express.test.js +86 -0
- package/dist/tests/filters.test.d.ts +13 -0
- package/dist/tests/filters.test.js +286 -0
- package/dist/tests/globals.test.d.ts +1 -0
- package/dist/tests/globals.test.js +579 -0
- package/dist/tests/interpreter.test.d.ts +1 -0
- package/dist/tests/interpreter.test.js +208 -0
- package/dist/tests/lexer.test.d.ts +1 -0
- package/dist/tests/lexer.test.js +249 -0
- package/dist/tests/lib.test.d.ts +1 -0
- package/dist/tests/lib.test.js +236 -0
- package/dist/tests/loader.test.d.ts +1 -0
- package/dist/tests/loader.test.js +301 -0
- package/dist/tests/nodes.test.d.ts +1 -0
- package/dist/tests/nodes.test.js +137 -0
- package/dist/tests/parser.test.d.ts +1 -0
- package/dist/tests/parser.test.js +294 -0
- package/dist/tests/precompile.test.d.ts +1 -0
- package/dist/tests/precompile.test.js +224 -0
- package/dist/tests/runtime.test.d.ts +1 -0
- package/dist/tests/runtime.test.js +237 -0
- package/dist/tests/transformer.test.d.ts +1 -0
- package/dist/tests/transformer.test.js +125 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
export declare abstract class Node {
|
|
2
|
+
lineno: number;
|
|
3
|
+
colno: number;
|
|
4
|
+
value?: any;
|
|
5
|
+
children: Node[];
|
|
6
|
+
body?: Node;
|
|
7
|
+
constructor(lineno?: number, colno?: number, // public extname = '', // public __typename: string = this.constructor.name, // public fields: string[] = []
|
|
8
|
+
value?: any);
|
|
9
|
+
abstract get typename(): NodeTypeKey;
|
|
10
|
+
get fields(): readonly string[];
|
|
11
|
+
static readonly fields: readonly string[];
|
|
12
|
+
findAll(this: Node, type: NodeTypeValue, results?: any[]): any[];
|
|
13
|
+
iterFields(this: any, func: Function): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class Slice extends Node {
|
|
16
|
+
start?: Literal;
|
|
17
|
+
stop?: Literal;
|
|
18
|
+
step?: Literal;
|
|
19
|
+
constructor(lineno: number, colno: number, start?: Literal, stop?: Literal, step?: Literal);
|
|
20
|
+
static readonly fields: readonly ["start", "stop", "step"];
|
|
21
|
+
get typename(): NodeTypeKey;
|
|
22
|
+
}
|
|
23
|
+
export declare class FromImport extends Node {
|
|
24
|
+
template?: string;
|
|
25
|
+
names?: NodeList;
|
|
26
|
+
withContext?: any;
|
|
27
|
+
constructor(lineno: number, colno: number, template?: string, names?: NodeList, withContext?: any);
|
|
28
|
+
static readonly fields: readonly ["template", "names", "withContext"];
|
|
29
|
+
get typename(): NodeTypeKey;
|
|
30
|
+
}
|
|
31
|
+
export declare class Pair extends Node {
|
|
32
|
+
key?: any;
|
|
33
|
+
constructor(lineno: number, colno: number, key?: any, value?: any);
|
|
34
|
+
static readonly fields: readonly ["key", "value"];
|
|
35
|
+
get typename(): NodeTypeKey;
|
|
36
|
+
}
|
|
37
|
+
export declare class LookupVal extends Node {
|
|
38
|
+
target?: any;
|
|
39
|
+
val?: any;
|
|
40
|
+
constructor(lineno: number, colno: number, target?: any, val?: any);
|
|
41
|
+
static readonly fields: readonly ["target", "val"];
|
|
42
|
+
get typename(): NodeTypeKey;
|
|
43
|
+
}
|
|
44
|
+
export declare class If extends Node {
|
|
45
|
+
cond?: any;
|
|
46
|
+
else_?: any;
|
|
47
|
+
constructor(lineno: number, colno: number, cond?: any, body?: any, else_?: any);
|
|
48
|
+
static readonly fields: readonly ["cond", "body", "else_"];
|
|
49
|
+
get typename(): NodeTypeKey;
|
|
50
|
+
}
|
|
51
|
+
export declare class InlineIf extends Node {
|
|
52
|
+
cond?: any;
|
|
53
|
+
else_?: any;
|
|
54
|
+
constructor(lineno: number, colno: number, cond?: any, body?: any, else_?: any);
|
|
55
|
+
static readonly fields: readonly ["cond", "body", "else_"];
|
|
56
|
+
get typename(): NodeTypeKey;
|
|
57
|
+
}
|
|
58
|
+
export declare class For extends Node {
|
|
59
|
+
arr: any;
|
|
60
|
+
name?: Symbol;
|
|
61
|
+
else_?: any;
|
|
62
|
+
static readonly fields: readonly ["arr", "name", "body", "else_"];
|
|
63
|
+
constructor(lineno: number, colno: number, arr?: any, name?: Symbol, body?: any, else_?: any);
|
|
64
|
+
get typename(): NodeTypeKey;
|
|
65
|
+
}
|
|
66
|
+
export declare class Macro extends Node {
|
|
67
|
+
name?: Symbol;
|
|
68
|
+
args?: any;
|
|
69
|
+
constructor(lineno: number, colno: number, name?: Symbol, args?: any, body?: NodeList);
|
|
70
|
+
static fields: string[];
|
|
71
|
+
get typename(): NodeTypeKey;
|
|
72
|
+
}
|
|
73
|
+
export declare class Import extends Node {
|
|
74
|
+
template?: any;
|
|
75
|
+
target?: any;
|
|
76
|
+
withContext?: any;
|
|
77
|
+
static readonly fields: readonly ["template", "target", "withContext"];
|
|
78
|
+
get typename(): NodeTypeKey;
|
|
79
|
+
constructor(lineno: number, colno: number, template?: any, target?: any, withContext?: any);
|
|
80
|
+
}
|
|
81
|
+
export declare class Block extends Node {
|
|
82
|
+
body?: any;
|
|
83
|
+
name?: Node | Value;
|
|
84
|
+
constructor(lineno: number, colno: number, body?: any, name?: Node | Value);
|
|
85
|
+
static readonly fields: readonly ["name", "body"];
|
|
86
|
+
get typename(): NodeTypeKey;
|
|
87
|
+
}
|
|
88
|
+
export declare class Super extends Node {
|
|
89
|
+
blockName?: any;
|
|
90
|
+
symbol?: Symbol;
|
|
91
|
+
constructor(lineno: number, colno: number, blockName?: any, symbol?: Symbol);
|
|
92
|
+
static readonly fields: readonly ["blockName", "symbol"];
|
|
93
|
+
get typename(): NodeTypeKey;
|
|
94
|
+
}
|
|
95
|
+
export declare class TemplateRef extends Node {
|
|
96
|
+
template?: any;
|
|
97
|
+
constructor(lineno: number, colno: number, template?: any);
|
|
98
|
+
static readonly fields: readonly ["template"];
|
|
99
|
+
get typename(): NodeTypeKey;
|
|
100
|
+
}
|
|
101
|
+
export declare class FunCall extends Node {
|
|
102
|
+
name?: Node;
|
|
103
|
+
args?: any;
|
|
104
|
+
constructor(lineno: number, colno: number, name?: Node, args?: any);
|
|
105
|
+
static readonly fields: readonly ["name", "args"];
|
|
106
|
+
get typename(): NodeTypeKey;
|
|
107
|
+
}
|
|
108
|
+
export declare class Include extends Node {
|
|
109
|
+
template?: any[];
|
|
110
|
+
ignoreMissing: boolean;
|
|
111
|
+
constructor(lineno: number, colno: number, template?: any[], ignoreMissing?: boolean);
|
|
112
|
+
static readonly fields: readonly ["template", "ignoreMissing"];
|
|
113
|
+
get typename(): NodeTypeKey;
|
|
114
|
+
}
|
|
115
|
+
export declare class Set extends Node {
|
|
116
|
+
targets: any;
|
|
117
|
+
constructor(lineno: number, colno: number, targets?: any[], value?: any);
|
|
118
|
+
static readonly fields: readonly ["targets", "value"];
|
|
119
|
+
get typename(): NodeTypeKey;
|
|
120
|
+
}
|
|
121
|
+
export declare class Switch extends Node {
|
|
122
|
+
expr?: any;
|
|
123
|
+
cases?: any;
|
|
124
|
+
_default?: any;
|
|
125
|
+
constructor(lineno: number, colno: number, expr?: any, cases?: any, _default?: any);
|
|
126
|
+
static readonly fields: readonly ["expr", "cases", "default"];
|
|
127
|
+
get typename(): NodeTypeKey;
|
|
128
|
+
}
|
|
129
|
+
export declare class Case extends Node {
|
|
130
|
+
cond?: any;
|
|
131
|
+
constructor(lineno: number, colno: number, cond?: any, body?: any);
|
|
132
|
+
static readonly fields: readonly ["cond", "body"];
|
|
133
|
+
get typename(): NodeTypeKey;
|
|
134
|
+
}
|
|
135
|
+
export declare class Output extends Node {
|
|
136
|
+
get typename(): NodeTypeKey;
|
|
137
|
+
constructor(lineno: number, colno: number, args?: Node[]);
|
|
138
|
+
}
|
|
139
|
+
export declare class Capture extends Node {
|
|
140
|
+
constructor(lineno: number, colno: number, body?: NodeList);
|
|
141
|
+
static readonly fields: readonly ["body"];
|
|
142
|
+
get typename(): NodeTypeKey;
|
|
143
|
+
}
|
|
144
|
+
export declare class UnaryOp extends Node {
|
|
145
|
+
target?: any;
|
|
146
|
+
constructor(lineno: number, colno: number, target?: any);
|
|
147
|
+
static readonly fields: readonly ["target"];
|
|
148
|
+
get typename(): NodeTypeKey;
|
|
149
|
+
}
|
|
150
|
+
export declare class BinOp extends Node {
|
|
151
|
+
left?: any;
|
|
152
|
+
right?: any;
|
|
153
|
+
constructor(lineno: number, colno: number, left?: any, right?: any);
|
|
154
|
+
static readonly fields: readonly ["left", "right"];
|
|
155
|
+
get typename(): NodeTypeKey;
|
|
156
|
+
}
|
|
157
|
+
export declare class Compare extends Node {
|
|
158
|
+
expr?: any;
|
|
159
|
+
ops: any[];
|
|
160
|
+
constructor(lineno: number, colno: number, expr?: any, ops?: any[]);
|
|
161
|
+
static readonly fields: readonly ["expr", "ops"];
|
|
162
|
+
get typename(): NodeTypeKey;
|
|
163
|
+
}
|
|
164
|
+
export declare class CompareOperand extends Node {
|
|
165
|
+
expr?: any;
|
|
166
|
+
type?: any;
|
|
167
|
+
constructor(lineno: number, colno: number, expr?: any, type?: any);
|
|
168
|
+
static readonly fields: readonly ["expr", "type"];
|
|
169
|
+
get typename(): NodeTypeKey;
|
|
170
|
+
}
|
|
171
|
+
export declare class CallExtension extends Node {
|
|
172
|
+
ext?: {
|
|
173
|
+
__name: string;
|
|
174
|
+
autoescape: any;
|
|
175
|
+
} | string;
|
|
176
|
+
prop?: any;
|
|
177
|
+
args?: NodeList;
|
|
178
|
+
contentArgs: any[];
|
|
179
|
+
extname: string;
|
|
180
|
+
autoescape: any;
|
|
181
|
+
static readonly fields: readonly ["extname", "prop", "args", "contentArgs"];
|
|
182
|
+
get typename(): NodeTypeKey;
|
|
183
|
+
constructor(lineno: number, colno: number, ext?: {
|
|
184
|
+
__name: string;
|
|
185
|
+
autoescape: any;
|
|
186
|
+
} | string, prop?: any, args?: NodeList, contentArgs?: any[]);
|
|
187
|
+
}
|
|
188
|
+
export declare class Value extends Node {
|
|
189
|
+
value?: any;
|
|
190
|
+
static readonly fields: readonly ["value"];
|
|
191
|
+
get typename(): NodeTypeKey;
|
|
192
|
+
constructor(lineno: number, colno: number, value?: any);
|
|
193
|
+
}
|
|
194
|
+
export declare class Literal extends Value {
|
|
195
|
+
get typename(): NodeTypeKey;
|
|
196
|
+
}
|
|
197
|
+
export declare class Symbol extends Value {
|
|
198
|
+
get typename(): NodeTypeKey;
|
|
199
|
+
}
|
|
200
|
+
export declare class NodeList extends Node {
|
|
201
|
+
children: Node[];
|
|
202
|
+
static readonly fields: readonly ["children"];
|
|
203
|
+
get typename(): NodeTypeKey;
|
|
204
|
+
constructor(lineno?: number, colno?: number, children?: Node[]);
|
|
205
|
+
addChild(node: Node): void;
|
|
206
|
+
}
|
|
207
|
+
export declare class Root extends NodeList {
|
|
208
|
+
get typename(): NodeTypeKey;
|
|
209
|
+
}
|
|
210
|
+
export declare class Group extends NodeList {
|
|
211
|
+
get typename(): NodeTypeKey;
|
|
212
|
+
}
|
|
213
|
+
export declare class ArrayNode extends NodeList {
|
|
214
|
+
get typename(): NodeTypeKey;
|
|
215
|
+
}
|
|
216
|
+
export declare class Dict extends NodeList {
|
|
217
|
+
get typename(): NodeTypeKey;
|
|
218
|
+
}
|
|
219
|
+
export declare class IfAsync extends If {
|
|
220
|
+
get typename(): NodeTypeKey;
|
|
221
|
+
}
|
|
222
|
+
export declare class AsyncEach extends For {
|
|
223
|
+
get typename(): NodeTypeKey;
|
|
224
|
+
}
|
|
225
|
+
export declare class AsyncAll extends For {
|
|
226
|
+
get typename(): NodeTypeKey;
|
|
227
|
+
}
|
|
228
|
+
export declare class Caller extends Macro {
|
|
229
|
+
get typename(): NodeTypeKey;
|
|
230
|
+
}
|
|
231
|
+
export declare class Filter extends Macro {
|
|
232
|
+
get typename(): NodeTypeKey;
|
|
233
|
+
}
|
|
234
|
+
export declare class FilterAsync extends Filter {
|
|
235
|
+
name?: Symbol;
|
|
236
|
+
args?: any;
|
|
237
|
+
symbol?: Symbol;
|
|
238
|
+
static readonly fields: readonly string[];
|
|
239
|
+
constructor(lineno: number, colno: number, name?: Symbol, args?: any, symbol?: Symbol);
|
|
240
|
+
get typename(): NodeTypeKey;
|
|
241
|
+
}
|
|
242
|
+
export declare class KeywordArgs extends Dict {
|
|
243
|
+
constructor(lineno?: number, colno?: number);
|
|
244
|
+
get typename(): NodeTypeKey;
|
|
245
|
+
}
|
|
246
|
+
export declare class Extends extends TemplateRef {
|
|
247
|
+
get typename(): NodeTypeKey;
|
|
248
|
+
}
|
|
249
|
+
export declare class TemplateData extends Literal {
|
|
250
|
+
get typename(): NodeTypeKey;
|
|
251
|
+
}
|
|
252
|
+
export declare class In extends BinOp {
|
|
253
|
+
get typename(): NodeTypeKey;
|
|
254
|
+
}
|
|
255
|
+
export declare class Is extends BinOp {
|
|
256
|
+
get typename(): NodeTypeKey;
|
|
257
|
+
}
|
|
258
|
+
export declare class Or extends BinOp {
|
|
259
|
+
get typename(): NodeTypeKey;
|
|
260
|
+
}
|
|
261
|
+
export declare class And extends BinOp {
|
|
262
|
+
get typename(): NodeTypeKey;
|
|
263
|
+
}
|
|
264
|
+
export declare class Add extends BinOp {
|
|
265
|
+
get typename(): NodeTypeKey;
|
|
266
|
+
}
|
|
267
|
+
export declare class Concat extends BinOp {
|
|
268
|
+
get typename(): NodeTypeKey;
|
|
269
|
+
}
|
|
270
|
+
export declare class Sub extends BinOp {
|
|
271
|
+
get typename(): NodeTypeKey;
|
|
272
|
+
}
|
|
273
|
+
export declare class Mul extends BinOp {
|
|
274
|
+
get typename(): NodeTypeKey;
|
|
275
|
+
}
|
|
276
|
+
export declare class Div extends BinOp {
|
|
277
|
+
get typename(): NodeTypeKey;
|
|
278
|
+
}
|
|
279
|
+
export declare class FloorDiv extends BinOp {
|
|
280
|
+
get typename(): NodeTypeKey;
|
|
281
|
+
}
|
|
282
|
+
export declare class Mod extends BinOp {
|
|
283
|
+
get typename(): NodeTypeKey;
|
|
284
|
+
}
|
|
285
|
+
export declare class Pow extends BinOp {
|
|
286
|
+
get typename(): NodeTypeKey;
|
|
287
|
+
}
|
|
288
|
+
export declare class Not extends UnaryOp {
|
|
289
|
+
get typename(): NodeTypeKey;
|
|
290
|
+
}
|
|
291
|
+
export declare class Neg extends UnaryOp {
|
|
292
|
+
get typename(): NodeTypeKey;
|
|
293
|
+
}
|
|
294
|
+
export declare class Pos extends UnaryOp {
|
|
295
|
+
get typename(): NodeTypeKey;
|
|
296
|
+
}
|
|
297
|
+
export declare class CallExtensionAsync extends CallExtension {
|
|
298
|
+
name: any;
|
|
299
|
+
get typename(): NodeTypeKey;
|
|
300
|
+
}
|
|
301
|
+
export declare function printNodes(node: any, indent?: number): void;
|
|
302
|
+
declare const NodeTypes: {
|
|
303
|
+
readonly Add: typeof Add;
|
|
304
|
+
readonly And: typeof And;
|
|
305
|
+
readonly Array: typeof ArrayNode;
|
|
306
|
+
readonly AsyncEach: typeof AsyncEach;
|
|
307
|
+
readonly AsyncAll: typeof AsyncAll;
|
|
308
|
+
readonly BinOp: typeof BinOp;
|
|
309
|
+
readonly Block: typeof Block;
|
|
310
|
+
readonly Caller: typeof Caller;
|
|
311
|
+
readonly CallExtension: typeof CallExtension;
|
|
312
|
+
readonly CallExtensionAsync: typeof CallExtensionAsync;
|
|
313
|
+
readonly Capture: typeof Capture;
|
|
314
|
+
readonly Case: typeof Case;
|
|
315
|
+
readonly Compare: typeof Compare;
|
|
316
|
+
readonly CompareOperand: typeof CompareOperand;
|
|
317
|
+
readonly Concat: typeof Concat;
|
|
318
|
+
readonly Dict: typeof Dict;
|
|
319
|
+
readonly Div: typeof Div;
|
|
320
|
+
readonly Extends: typeof Extends;
|
|
321
|
+
readonly Filter: typeof Filter;
|
|
322
|
+
readonly FilterAsync: typeof FilterAsync;
|
|
323
|
+
readonly FloorDiv: typeof FloorDiv;
|
|
324
|
+
readonly For: typeof For;
|
|
325
|
+
readonly FromImport: typeof FromImport;
|
|
326
|
+
readonly FunCall: typeof FunCall;
|
|
327
|
+
readonly Group: typeof Group;
|
|
328
|
+
readonly If: typeof If;
|
|
329
|
+
readonly IfAsync: typeof IfAsync;
|
|
330
|
+
readonly Import: typeof Import;
|
|
331
|
+
readonly In: typeof In;
|
|
332
|
+
readonly Include: typeof Include;
|
|
333
|
+
readonly InlineIf: typeof InlineIf;
|
|
334
|
+
readonly Is: typeof Is;
|
|
335
|
+
readonly KeywordArgs: typeof KeywordArgs;
|
|
336
|
+
readonly Literal: typeof Literal;
|
|
337
|
+
readonly LookupVal: typeof LookupVal;
|
|
338
|
+
readonly Macro: typeof Macro;
|
|
339
|
+
readonly Mod: typeof Mod;
|
|
340
|
+
readonly Mul: typeof Mul;
|
|
341
|
+
readonly Neg: typeof Neg;
|
|
342
|
+
readonly NodeList: typeof NodeList;
|
|
343
|
+
readonly Not: typeof Not;
|
|
344
|
+
readonly Or: typeof Or;
|
|
345
|
+
readonly Output: typeof Output;
|
|
346
|
+
readonly Pair: typeof Pair;
|
|
347
|
+
readonly Pos: typeof Pos;
|
|
348
|
+
readonly Pow: typeof Pow;
|
|
349
|
+
readonly Root: typeof Root;
|
|
350
|
+
readonly Set: typeof Set;
|
|
351
|
+
readonly Slice: typeof Slice;
|
|
352
|
+
readonly Sub: typeof Sub;
|
|
353
|
+
readonly Super: typeof Super;
|
|
354
|
+
readonly Switch: typeof Switch;
|
|
355
|
+
readonly Symbol: typeof Symbol;
|
|
356
|
+
readonly TemplateData: typeof TemplateData;
|
|
357
|
+
readonly Value: typeof Value;
|
|
358
|
+
};
|
|
359
|
+
export type NodeTypeKey = keyof typeof NodeTypes;
|
|
360
|
+
export type NodeTypeValue = (typeof NodeTypes)[NodeTypeKey];
|
|
361
|
+
export declare const NodeCreator: (key: NodeTypeKey) => typeof Slice | typeof Add | typeof ArrayNode | typeof AsyncEach | typeof Block | typeof Caller | typeof CallExtension | typeof Capture | typeof Case | typeof Compare | typeof CompareOperand | typeof FilterAsync | typeof FromImport | typeof FunCall | typeof If | typeof Import | typeof Include | typeof LookupVal | typeof Output | typeof Pair | typeof Set | typeof Super | typeof Switch;
|
|
362
|
+
export {};
|