From c41bc8f1b4b8c70b36989860d3257ad6ae792979 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 12 May 2023 10:28:44 +0800 Subject: [PATCH] fix: preparse template before rendering --- src/main.ts | 4 ++++ src/settings/template.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/main.ts b/src/main.ts index c975250..8f0c3c4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,6 +20,7 @@ import { } from "./settings"; import { FolderSuggest } from "./settings/file-suggest"; import { + preParseTemplate, renderArticleContnet, renderAttachmentFolder, renderFilename, @@ -152,6 +153,9 @@ export default class OmnivorePlugin extends Plugin { new Notice("🚀 Fetching articles ..."); + // pre-parse template + preParseTemplate(template); + const size = 50; for ( let hasNextPage = true, articles: Article[] = [], after = 0; diff --git a/src/settings/template.ts b/src/settings/template.ts index 65fbaf8..6b6fb80 100644 --- a/src/settings/template.ts +++ b/src/settings/template.ts @@ -281,3 +281,7 @@ export const renderFolderName = (folder: string, folderDate: string) => { date: folderDate, }); }; + +export const preParseTemplate = (template: string) => { + Mustache.parse(template); +};