-
-
Notifications
You must be signed in to change notification settings - Fork 197
Expand file tree
/
Copy pathSingleTemplateEngine.ts
More file actions
38 lines (34 loc) · 1.11 KB
/
Copy pathSingleTemplateEngine.ts
File metadata and controls
38 lines (34 loc) · 1.11 KB
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
import { TemplateEngine } from "./TemplateEngine";
import type { App } from "obsidian";
import type QuickAdd from "../main";
import type { IChoiceExecutor } from "../IChoiceExecutor";
import { log } from "../logger/logManager";
export class SingleTemplateEngine extends TemplateEngine {
constructor(
app: App,
plugin: QuickAdd,
private templatePath: string,
choiceExecutor?: IChoiceExecutor
) {
super(app, plugin, choiceExecutor);
}
public async run(): Promise<string> {
let templateContent: string = await this.getTemplateContent(
this.templatePath
);
if (!templateContent) {
log.logError(`Template ${this.templatePath} not found.`);
}
templateContent = await this.formatter.withTemplatePropertyCollection(
() => this.formatter.formatFileContent(templateContent),
);
return templateContent;
}
/**
* Returns the template variables that should be processed as proper property types.
* Note: This method clears the internal state after returning the variables.
*/
public getAndClearTemplatePropertyVars(): Map<string, unknown> {
return this.formatter.getAndClearTemplatePropertyVars();
}
}