-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.d.ts
121 lines (104 loc) · 4.7 KB
/
node.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Type definitions for gaikan v2.0.2
// Project: https://github.com/Deathspike/gaikan
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
// Definitions: https://github.com/typed-contrib/gaikan
/**
* Compiles a function for the input file, invokes it, and returns the output.
* @param input - The path to the template file.
* @param root - Data to be injected into the template.
* @returns The compiled template.
*/
declare function gaikan(input: string, root: any): string;
/**
* Compiles a function for the input file, invokes it, and returns the output.
* @param input - The path to the template file.
* @param root - Data to be injected into the template.
* @param fragments - Each fragment.
* @returns The compiled template.
*/
declare function gaikan(input: string, root: any, fragments: gaikan.Fragments): string;
/**
* Compiles a function for the input file, invokes it, and returns the output.
* @param input - The path to the template file.
* @param root - Data to be injected into the template.
* @param skipLayout - Indicates if the layout is skipped.
* @param fragments - Each fragment.
* @returns The compiled template.
*/
declare function gaikan(input: string, root: any, fragments: gaikan.Fragments, skipLayout: boolean): string;
/**
* Compiles a function for the input file, invokes it, and returns the output in the given callback.
* @param input - The path to the template file.
* @param root - Data to be injected into the template.
* @param callback - The result callback.
*/
declare function gaikan(input: string, root: any, callback: (result: string) => void): number;
/**
* Compiles a function for the input file, invokes it, and returns the output in the given callback.
* @param input - The path to the template file.
* @param root - Data to be injected into the template.
* @param fragments - Each fragment.
* @param callback - The result callback.
*/
declare function gaikan(input: string, root: any, fragments: gaikan.Fragments, callback: (result: string) => void): number;
/**
* Compiles a function for the input file, invokes it, and returns the output in the given callback.
* @param input - The path to the template file.
* @param root - Data to be injected into the template.
* @param fragments - Each fragment.
* @param callback - The result callback.
* @param skipLayout - Indicates if the layout is skipped.
*/
declare function gaikan(input: string, root: any, fragments: gaikan.Fragments, callback: (result: string) => void, skipLayout: boolean): number;
declare namespace gaikan {
export type Fragments = { [key: string]: (runtime: typeof gaikan, root: any) => string; };
export type TemplateFunction = (__r: typeof gaikan, root: any, __f?: Fragments) => string;
export type AlterantFunction = (value: any) => string;
export type SetFunction = (value: any) => string;
export interface Alterants {
[key: string]: AlterantFunction;
break: AlterantFunction;
decode: AlterantFunction;
encode: AlterantFunction;
lower: AlterantFunction;
title: AlterantFunction;
upper: AlterantFunction;
url: AlterantFunction;
}
export interface Sets {
[key: string]: SetFunction;
empty: SetFunction;
sort: SetFunction;
}
export interface Options {
/** Enables or disables template caching. When enabled, a compiled template is not compiled again. */
enableCache: boolean;
/** Enables or disables template compression. When enabled, compiled functions compress output. */
enableCompression: boolean;
/** An array with relative directories in which to search templates. Usused for expressjs. */
directories: string[];
/** Templates resolve from the root directory, which defaults to the main script directory. */
rootDir: string;
/** An array with allowed template file extensions. Usused for expressjs. */
extensions: string[];
/** Changes output to be the content fragment for the layout. Used when skipLayout is false. */
layout: string;
}
/** Adding functions makes them available in each template. */
export const alterant: Alterants;
/** Adding functions makes them available in each template. */
export const set: Sets;
/** Gaikan options. */
export const options: Options;
/**
* Compiles a function for the input file.
* @param path - The input file path.
*/
export function compileFromFile(path: string): TemplateFunction;
/**
* Compiles a function for the input string.
* @param path - The input template string.
*/
export function compileFromString(input: string): TemplateFunction;
}
export = gaikan;