-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathtemplatePlugin.ts
46 lines (39 loc) · 1.38 KB
/
templatePlugin.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
import { ScopeData, Tag, TemplateCompiler, TemplateContext } from '../compilation';
import { DocxParser } from '../office';
import { XmlParser } from '../xml';
export interface PluginUtilities {
compiler: TemplateCompiler;
docxParser: DocxParser;
xmlParser: XmlParser;
}
export abstract class TemplatePlugin {
/**
* The content type this plugin handles.
*/
public abstract readonly contentType: string;
protected utilities: PluginUtilities;
/**
* Called by the TemplateHandler at runtime.
*/
public setUtilities(utilities: PluginUtilities): void {
this.utilities = utilities;
}
/**
* This method is called for each self-closing tag.
* It should implement the specific document manipulation required by the tag.
*/
public simpleTagReplacements(tag: Tag, data: ScopeData, context: TemplateContext): void | Promise<void> {
// noop
}
/**
* This method is called for each container tag. It should implement the
* specific document manipulation required by the tag.
*
* @param tags All tags between the opening tag and closing tag (inclusive,
* i.e. tags[0] is the opening tag and the last item in the tags array is
* the closing tag).
*/
public containerTagReplacements(tags: Tag[], data: ScopeData, context: TemplateContext): void | Promise<void> {
// noop
}
}