aboutsummaryrefslogtreecommitdiff
path: root/extension/decl/handlebars/handlebars-1.0.0.d.ts
blob: c118760c508463756182fb6d20af78cc25b01168 (plain)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// Type definitions for Handlebars 1.0
// Project: http://handlebarsjs.com/
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped


// Use either HandlebarsStatic or HandlebarsRuntimeStatic
declare var Handlebars: HandlebarsStatic;
//declare var Handlebars: HandlebarsRuntimeStatic;

/**
* Implement this interface on your MVW/MVVM/MVC views such as Backbone.View
**/
interface HandlebarsTemplatable {
    template: HandlebarsTemplateDelegate;
}

interface HandlebarsTemplateDelegate {
    (context: any, options?: any): string;
}

interface HandlebarsCommon {
    registerHelper(name: string, fn: Function, inverse?: boolean): void;
    registerPartial(name: string, str: any): void;
    K(): void;
    createFrame(object: any): any;

    Exception(message: string): void;
    SafeString: typeof hbs.SafeString;
    Utils: typeof hbs.Utils;

    logger: Logger;
    log(level: number, obj: any): void;
}

interface HandlebarsStatic extends HandlebarsCommon {
    parse(input: string): hbs.AST.ProgramNode;
    compile(input: any, options?: any): HandlebarsTemplateDelegate;
}

interface HandlebarsTemplates {
    [index: string]: HandlebarsTemplateDelegate;
}

interface HandlebarsRuntimeStatic extends HandlebarsCommon {
    // Handlebars.templates is the default template namespace in precompiler.
    templates: HandlebarsTemplates;
}

declare module hbs {
    class SafeString {
        constructor(str: string);
        static toString(): string;
    }

    module Utils {
        function escapeExpression(str: string): string;
    }
}

interface Logger {
    DEBUG: number;
    INFO: number;
    WARN: number;
    ERROR: number;
    level: number;

    methodMap: { [level: number]: string };

    log(level: number, obj: string): void;
}

declare module hbs {
    module AST {
        interface IStripInfo {
            left?: boolean;
            right?: boolean;
            inlineStandalone?: boolean;
        }

        class NodeBase {
            firstColumn: number;
            firstLine: number;
            lastColumn: number;
            lastLine: number;
            type: string;
        }

        class ProgramNode extends NodeBase {
            statements: NodeBase[];
        }

        class IdNode extends NodeBase {
            original: string;
            parts: string[];
            string: string;
            depth: number;
            idName: string;
            isSimple: boolean;
            stringModeValue: string;
        }

        class HashNode extends NodeBase {
            pairs: {0: string;
                    1: NodeBase}[];
        }

        class SexprNode extends NodeBase {
            hash: HashNode;
            id: NodeBase;
            params: NodeBase[];
            isHelper: boolean;
            eligibleHelper: boolean;
        }

        class MustacheNode extends NodeBase {
            strip: IStripInfo;
            escaped: boolean;
            sexpr: SexprNode;

        }

        class BlockNode extends NodeBase {
            mustache: MustacheNode;
            program: ProgramNode;
            inverse: ProgramNode;
            strip: IStripInfo;
            isInverse: boolean;
        }

        class PartialNameNode extends NodeBase {
            name: string;
        }

        class PartialNode extends NodeBase {
            partialName: PartialNameNode;
            context: NodeBase;
            hash: HashNode;
            strip: IStripInfo;
        }

        class RawBlockNode extends NodeBase {
            mustache: MustacheNode;
            program: ProgramNode;
        }

        class ContentNode extends NodeBase {
            original: string;
            string: string;
        }

        class DataNode extends NodeBase {
            id: IdNode;
            stringModeValue: string;
            idName: string;
        }

        class StringNode extends NodeBase {
            original: string;
            string: string;
            stringModeValue: string;
        }

        class NumberNode extends NodeBase {
            original: string;
            number: string;
            stringModeValue: number;
        }

        class BooleanNode extends NodeBase {
            bool: string;
            stringModeValue: boolean;
        }

        class CommentNode extends NodeBase {
            comment: string;
            strip: IStripInfo;
        }
    }
}

declare module "handlebars" {
    export = Handlebars;
}