Skip to content

Commit 8d18699

Browse files
committed
Template: Fix template path error when no .md extension
1 parent eb5d966 commit 8d18699

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ Quickly add new pages or content to your vault.
99
You can also do a [manual installation](docs/ManualInstallation.md).
1010

1111
## What's new?
12-
### 0.3.6 - 0.3.8
12+
### 0.3.6 - 0.3.9
1313
- Added setting to create the 'Insert After' line if it isn't found.
14-
- (HOTFIX) Escape regular expression special characters in Insert After when searching for it
15-
- (HOTFIX) Insert _after_ frontmatter
14+
- (HOTFIX) Escape regular expression special characters in Insert After when searching for it.
15+
- (HOTFIX) Insert _after_ frontmatter.
16+
- (HOTFIX) Fix template choice file name gives error when there is no ``.md`` extension on the path.
1617

1718
### 0.3.5
1819
- You can now execute [inline JavaScript](docs/InlineScripts.md) in templates or captures.

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "quickadd",
33
"name": "QuickAdd",
4-
"version": "0.3.8",
4+
"version": "0.3.9",
55
"minAppVersion": "0.12.5",
66
"description": "Quickly add new pages or content to your vault.",
77
"author": "Christian B. B. Houmann",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "quickadd",
3-
"version": "0.3.8",
3+
"version": "0.3.9",
44
"description": "Quickly add new pages or content to your vault.",
55
"main": "main.js",
66
"scripts": {

src/engine/TemplateEngine.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {App, TAbstractFile, TFile} from "obsidian";
44
import type QuickAdd from "../main";
55
import {getTemplater, replaceTemplaterTemplatesInCreatedFile} from "../utility";
66
import GenericSuggester from "../gui/GenericSuggester/genericSuggester";
7-
import {FILE_NUMBER_REGEX} from "../constants";
7+
import {FILE_NUMBER_REGEX, MARKDOWN_FILE_EXTENSION_REGEX} from "../constants";
88
import {log} from "../logger/logManager";
99
import type {IChoiceExecutor} from "../IChoiceExecutor";
1010

@@ -120,7 +120,11 @@ export abstract class TemplateEngine extends QuickAddEngine {
120120
}
121121

122122
protected async getTemplateContent(templatePath: string): Promise<string> {
123-
const templateFile: TAbstractFile = this.app.vault.getAbstractFileByPath(templatePath);
123+
let correctTemplatePath: string = templatePath;
124+
if (!MARKDOWN_FILE_EXTENSION_REGEX.test(templatePath))
125+
correctTemplatePath += ".md";
126+
127+
const templateFile: TAbstractFile = this.app.vault.getAbstractFileByPath(correctTemplatePath);
124128
if (!(templateFile instanceof TFile)) return;
125129

126130
return await this.app.vault.cachedRead(templateFile);

versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"0.2.16": "0.12.4",
3-
"0.3.8": "0.12.5"
3+
"0.3.9": "0.12.5"
44
}

0 commit comments

Comments
 (0)