File tree Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -284,7 +284,7 @@ export class CaptureChoiceEngine extends QuickAddChoiceEngine {
284
284
}
285
285
286
286
const file : TFile = await this . createFileWithInput ( filePath , fileContent ) ;
287
- await replaceTemplaterTemplatesInCreatedFile ( this . app , file ) ;
287
+ await replaceTemplaterTemplatesInCreatedFile ( this . app , file , true ) ;
288
288
289
289
const updatedFileContent : string = await this . app . vault . cachedRead ( file ) ;
290
290
const newFileContent : string = await this . formatter . formatContentWithFile (
Original file line number Diff line number Diff line change @@ -106,7 +106,8 @@ export abstract class TemplateEngine extends QuickAddEngine {
106
106
formattedTemplateContent
107
107
) ;
108
108
109
- await replaceTemplaterTemplatesInCreatedFile ( this . app , createdFile ) ;
109
+ // Always force processing of Templater commands for template choices
110
+ await replaceTemplaterTemplatesInCreatedFile ( this . app , createdFile , true ) ;
110
111
111
112
return createdFile ;
112
113
} catch ( e ) {
@@ -132,6 +133,7 @@ export abstract class TemplateEngine extends QuickAddEngine {
132
133
await this . formatter . formatFileContent ( templateContent ) ;
133
134
await this . app . vault . modify ( file , formattedTemplateContent ) ;
134
135
136
+ // Already forcing Templater processing, keep this as-is
135
137
await replaceTemplaterTemplatesInCreatedFile ( this . app , file , true ) ;
136
138
137
139
return file ;
@@ -160,6 +162,7 @@ export abstract class TemplateEngine extends QuickAddEngine {
160
162
: `${ fileContent } \n${ formattedTemplateContent } ` ;
161
163
await this . app . vault . modify ( file , newFileContent ) ;
162
164
165
+ // Already forcing Templater processing, keep this as-is
163
166
await replaceTemplaterTemplatesInCreatedFile ( this . app , file , true ) ;
164
167
165
168
return file ;
Original file line number Diff line number Diff line change @@ -25,14 +25,16 @@ export async function replaceTemplaterTemplatesInCreatedFile(
25
25
force = false ,
26
26
) {
27
27
const templater = getTemplater ( app ) ;
28
-
29
- if (
30
- templater &&
31
- ( force ||
32
- ! ( templater . settings as Record < string , unknown > ) [
33
- "trigger_on_file_creation"
34
- ] )
35
- ) {
28
+
29
+ if ( ! templater ) return ;
30
+
31
+ // Process Templater commands in these cases:
32
+ // 1. force=true (explicitly requested processing, e.g., for Template choices)
33
+ // 2. Templater's trigger_on_file_creation=false (manual processing required)
34
+ const shouldProcess = force ||
35
+ ! ( templater . settings as Record < string , unknown > ) [ "trigger_on_file_creation" ] ;
36
+
37
+ if ( shouldProcess ) {
36
38
const impl = templater ?. templater as {
37
39
overwrite_file_commands ?: ( file : TFile ) => Promise < void > ;
38
40
} ;
You can’t perform that action at this time.
0 commit comments