@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,103 @@
|
|
|
1
|
+
import EventEmitter from 'events';
|
|
2
|
+
import { Loader } from './loader';
|
|
3
|
+
import { IGlobals } from './globals';
|
|
4
|
+
import { Callback } from './types';
|
|
5
|
+
declare global {
|
|
6
|
+
interface Window {
|
|
7
|
+
nunjucksPrecompiled?: any;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
type getTemplateOps = {
|
|
11
|
+
eagerCompile?: boolean;
|
|
12
|
+
parentName?: string | null;
|
|
13
|
+
ignoreMissing?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type TemplateInfo = {
|
|
16
|
+
src: string;
|
|
17
|
+
path: string;
|
|
18
|
+
noCache?: boolean;
|
|
19
|
+
loader: any;
|
|
20
|
+
};
|
|
21
|
+
interface IEnvironmentOpts {
|
|
22
|
+
path?: string;
|
|
23
|
+
throwOnUndefined?: boolean;
|
|
24
|
+
autoescape?: boolean;
|
|
25
|
+
trimBlocks?: boolean;
|
|
26
|
+
lstripBlocks?: boolean;
|
|
27
|
+
dev?: boolean;
|
|
28
|
+
loaders?: Loader[];
|
|
29
|
+
}
|
|
30
|
+
export declare class Environment extends EventEmitter {
|
|
31
|
+
ctx?: Context;
|
|
32
|
+
globals?: IGlobals;
|
|
33
|
+
throwOnUndefined: boolean;
|
|
34
|
+
trimBlocks: boolean;
|
|
35
|
+
lstripBlocks: boolean;
|
|
36
|
+
dev: boolean;
|
|
37
|
+
autoescape: boolean;
|
|
38
|
+
loaders: Loader[];
|
|
39
|
+
asyncFilters: string[];
|
|
40
|
+
path: string;
|
|
41
|
+
extensionsList: any[];
|
|
42
|
+
extensions: Record<string, any>;
|
|
43
|
+
filters: Record<string, any>;
|
|
44
|
+
cache: Record<string, any>;
|
|
45
|
+
constructor(opts?: IEnvironmentOpts);
|
|
46
|
+
_initLoaders(): void;
|
|
47
|
+
invalidateCache(): void;
|
|
48
|
+
addExtension(name: string, extension: Record<string, any>): this;
|
|
49
|
+
removeExtension(name: string): void;
|
|
50
|
+
getExtension(name: string): any;
|
|
51
|
+
hasExtension(name: string): boolean;
|
|
52
|
+
addFilter(name: string, func: Function, async?: any[]): this;
|
|
53
|
+
getFilter(name: string): any;
|
|
54
|
+
resolveTemplate(loader: Loader, parentName: string, filename: string): string;
|
|
55
|
+
getTemplateInfo(name: string, opts?: getTemplateOps, cb?: (err: any, info?: TemplateInfo | null) => void): TemplateInfo | undefined;
|
|
56
|
+
getTemplate(name: any, cb?: Callback, opts?: getTemplateOps): any;
|
|
57
|
+
express(app: any): Environment;
|
|
58
|
+
render(name: string, ctx: any, cb?: Callback): void;
|
|
59
|
+
renderString(src: any, ctx: any, opts: any, cb?: Callback): any;
|
|
60
|
+
get typename(): string;
|
|
61
|
+
waterfall(tasks: any, callback: Callback, forceAsync: any): (tasks: any, done: Callback) => void;
|
|
62
|
+
}
|
|
63
|
+
export declare class Context {
|
|
64
|
+
ctx: Record<string, any>;
|
|
65
|
+
blocks: Record<string, any>;
|
|
66
|
+
env: Environment;
|
|
67
|
+
lineno: number;
|
|
68
|
+
colno: number;
|
|
69
|
+
exported: any[];
|
|
70
|
+
compiled: boolean;
|
|
71
|
+
constructor(ctx?: Record<string, any>, blocks?: Record<string, any>, env?: Environment, lineno?: number, colno?: number);
|
|
72
|
+
get typename(): string;
|
|
73
|
+
lookup(name: string): any;
|
|
74
|
+
setVariable(name: string, val: any): void;
|
|
75
|
+
getVariables(): Record<string, any>;
|
|
76
|
+
addBlock(name: string, block: any): this;
|
|
77
|
+
getBlock(name: string): any;
|
|
78
|
+
getSuper(env: Environment, name: string, block: any, frame: any, runtime: any, cb: Callback): void;
|
|
79
|
+
addExport(name: string): void;
|
|
80
|
+
getExported(): {};
|
|
81
|
+
}
|
|
82
|
+
type ITemplateSrc = {
|
|
83
|
+
type: 'code' | 'string';
|
|
84
|
+
obj: any;
|
|
85
|
+
};
|
|
86
|
+
export declare class Template {
|
|
87
|
+
lineno: number;
|
|
88
|
+
colno: number;
|
|
89
|
+
env: Environment;
|
|
90
|
+
tmplProps?: Record<string, any>;
|
|
91
|
+
tmplStr: string | Record<string, any>;
|
|
92
|
+
path: string;
|
|
93
|
+
blocks: any;
|
|
94
|
+
compiled: boolean;
|
|
95
|
+
rootRenderFunction: any;
|
|
96
|
+
constructor(src: ITemplateSrc | string, env: Environment, path: string, eagerCompile?: any, lineno?: number, colno?: number);
|
|
97
|
+
render(ctx: any, parentFrame?: any, cb?: Callback): any;
|
|
98
|
+
getExported(ctx: any, parentFrame: any, cb: Callback): void;
|
|
99
|
+
compile(): void;
|
|
100
|
+
_compile(): void;
|
|
101
|
+
_getBlocks(props: any): {};
|
|
102
|
+
}
|
|
103
|
+
export {};
|