-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser.d.ts
68 lines (56 loc) · 2.26 KB
/
browser.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
// 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 string.
*/
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 string.
*/
declare function gaikan(input: string, root: any, fragments: gaikan.Fragments): string;
declare namespace gaikan {
export type Fragments = { [key: string]: (runtime: typeof gaikan, root: any) => string; };
export type TemplateFunction = (runtime: typeof gaikan, root: any, fragments?: 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 compression. When enabled, compiled functions compress output. */
enableCompression: boolean;
}
/** 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 string.
* @param path - The input template string.
*/
export function compileFromString(input: string): TemplateFunction;
}
export = gaikan;