SilentVoid13/Templater

Trigger Templater on new file creation does not replace Templater commands

orossant opened this issue · 12 comments

Plugin information (please complete the following information):

  • OS: [e.g. Mac Sonoma 14.7]
  • Templater version: [2.8.2]
  • Obsidian version: [1.7.4]
  • Templater settings: has not changed

Describe the bug
The right template is used but not rendered

Expected behavior
The right template is used and rendered

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Can you provide step by step instructions, and the template you're testing with? Templater appears to be working fine for me.

Hi I appreciate your help. See below more details

I am using simple templater templates like this below (for meeting)
I have configured templater folder location with the correct folder where templates are stored
I have enable Trigger Templaters on new file creation
I have enable Folder templates so that when i create a new note from folder Meetings, it normally will used the defined Template.
I have also enabled Daily Note, to create daily note directly from double click on the day choosen in Calendar
I have 2 pain points :
1/When I double click on today in my Calendar, it creates a New Daily Note with the correct Template Dayly Notes, but the note is created, it is without the rendered version of the template.

2/When I am in the folder view, i select Meeting folder and right click to create a new note : it creates an empty note instead of using Meeting note Templates

See below the two templates used for daily note and meeting.

Any idea to solve these odd things ? thanks a lot

Template Daily Notes

creation date: <% tp.file.creation_date() %>
meditation: 1
weight: 95
pomodoros: 1
mood: 5
exercice: 1
reading: 1
summary: it's always day 1

Template Daily Notes

Daily Notes - <% tp.date.now("YYYY-MM-DD")

%>

<% tp.web.daily_quote() %>

Start of Day

  • Check Email
  • Check Calendar

Things to do

Template meeting

date: <% tp.date.now("YYYY-MM-DD") %>
type: meeting
company:
entity:
summary:

[[<% tp.file.title %>]]

Attendees

Goal/Agenda

Discussion notes

Action items

  • [ ]

I have done any update configuration before updating obsidian to latest version. It seems something is broken

my template is very similar and i am receiving this error after the update as well.

plugin:calendar:206 Failed to read the daily note template 'templates/daily' TypeError: Cannot read properties of null (reading 'path')
    at t.<anonymous> (app.js:1:733763)
    at app.js:1:237228
    at Object.next (app.js:1:237333)
    at app.js:1:236249
    at new Promise (<anonymous>)
    at v (app.js:1:235994)
    at t.read (app.js:1:733644)
    at t.<anonymous> (app.js:1:734006)
    at app.js:1:237228
    at Object.next (app.js:1:237333)
    at app.js:1:236249
    at new Promise (<anonymous>)
    at v (app.js:1:235994)
    at t.cachedRead (app.js:1:733906)
    at getTemplateInfo (plugin:calendar:200:38)
    at createDailyNote (plugin:calendar:226:49)
    at createFile (plugin:calendar:1051:33)
    at HTMLButtonElement.eval (plugin:calendar:1033:23)

I can post my template as well if that helps

I had same problem. The template used to work well, after update obsidian to 1.7.4, it does not rendered anymore.

rollback to 1.6.7, the same template works again.

Do not know why.

@orossant I tried both of your templates in my main vault, test vault, and the sandbox vault, with daily notes and folder templates setup, and Templater executed as expected.

Here is the output from the "Show debug info" command, from the sandbox vault test I did.

SYSTEM INFO:
	Obsidian version: v1.7.4
	Installer version: v1.7.4
	Operating system: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:21 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8103 23.6.0
	Login status: logged in
	Language: en
	Catalyst license: insider
	Insider build toggle: on
	Live preview: on
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 0
	Restricted mode: off
	Plugins installed: 1
	Plugins enabled: 1
		1: Templater v2.8.3

RECOMMENDATIONS:
	Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Can I get someone to try in the sandbox vault with just Templater installed to test folder templates, and to provide the output from the "Show debug info" command, to help me narrow down what the issue could be? I can't fix this if I can't reproduce this.

Steps:

  1. Open the sandbox vault.
  2. Install Templater.
  3. Create a template folder and another folder for the folder template tests.
  4. In the template folder, create a simple template with at least one Templater function.
  5. In Templater settings:
    1. Set the template folder.
    2. Enable "Trigger Templater on new file creation".
    3. Enable folder templates and create a folder template, using the template and folder from the previous steps.
  6. Right click on the folder and create a new note in that folder.
    1. This should insert the template into that newly created note, with no errors.

its something about how the the path is handled that changed. Here is a very plain template that fails

<%*
var d=tp.date.now("YYYY-MM-DD",0,tp.file.title,"YYYY-MM-DD")
%>
# <% tp.date.now("dddd") %>

it worked prior to the obisidian update and works if i revert. Here is the stack trace

plugin:calendar:206 Failed to read the daily note template 'templates/daily' TypeError: Cannot read properties of null (reading 'path')
    at t.<anonymous> (app.js:1:733763)
    at app.js:1:237228
    at Object.next (app.js:1:237333)
    at app.js:1:236249
    at new Promise (<anonymous>)
    at v (app.js:1:235994)
    at t.read (app.js:1:733644)
    at t.<anonymous> (app.js:1:734006)
    at app.js:1:237228
    at Object.next (app.js:1:237333)
    at app.js:1:236249
    at new Promise (<anonymous>)
    at v (app.js:1:235994)
    at t.cachedRead (app.js:1:733906)
    at getTemplateInfo (plugin:calendar:200:38)
    at createDailyNote (plugin:calendar:226:49)
    at createFile (plugin:calendar:1051:33)
    at HTMLButtonElement.eval (plugin:calendar:1033:23)

It does work ok on the sandbox. Just not sure what that null path is refering too

@tgruben That error message leads me to believe that it's an issue with the calendar plugin, or an issue with your settings for the calendar plugin. None of the stack trace mentions the Templater plugin, just the calendar plugin.

Is your daily note template in a folder called templates and called daily?

That is correct and templates is the template folder location in the settings. It only show's up in the console error when i create my new daily note, i set that up so long ago it maybe triggered some other way, i can't recall. I'll see if i can track it down. What is odd, the file gets created in the correct spot its just firing off the template that has the issue . Thx for the feedback

I did managed to get it working again adding a folder action, i'm still not sure of how all the plugins interact here, but all is good. Thanks for the attention on my part

I did managed to get it working again adding a folder action, i'm still not sure of how all the plugins interact here, but all is good. Thanks for the attention on my part

Edit: nvm, rebuilding my vault cache did the trick (?)

Could you point me in the right direction? I suddenly seem to suffer from the same thing, since today. It all worked yesterday and I haven't changed a thing except update the plugins and restarting Obsidian (but that was after it happened). Templater works on other templates, just not on the one created as daily note from the calendar plugin.

mmcc commented

I'm not sure if this is quite the right issue to post this on, but I think this is either an issue with Templater or Daily Notes/Obsidian itself. Posting here in case someone else has run into it/resolved it, but it seems like other folks are hitting it as well.

I'm on a pretty fresh install, Templater, Dataview, and Daily Notes are the only plugins I've got right now. Getting started with Obsidian so user error is certainly not out of the question, to be clear, but I think I've got everything set up correctly given the situations in which things work fine.

For me the issue of Templater not actually running replacements only happens on when I have Obsidian open up a new Daily Notes file on startup. It works correctly if I either:

  • Manually run Templater on the file after the note is generated at startup
  • Disable the auto create and use the "Open Today's Daily Note" button

I don't see any errors in the console on startup or anything along those lines. Here's my debug info if it's helpful.

SYSTEM INFO:
	Obsidian version: v1.7.7
	Installer version: v1.7.6
	Operating system: Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:18 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T8122 24.0.0
	Login status: not logged in
	Language: en
	Insider build toggle: off
	Live preview: on
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 0
	Restricted mode: off
	Plugins installed: 2
	Plugins enabled: 2
		1: Dataview v0.5.67
		2: Templater v2.9.1

RECOMMENDATIONS:
	Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.