Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger Templater on new file creation does not replace Templater commands #1485

Open
orossant opened this issue Oct 17, 2024 · 14 comments
Open
Labels
bug Something isn't working

Comments

@orossant
Copy link

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.

@orossant orossant added the bug Something isn't working label Oct 17, 2024
@Zachatoo
Copy link
Collaborator

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

@orossant
Copy link
Author

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

  • [ ]

@orossant
Copy link
Author

orossant commented Oct 18, 2024

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

@tgruben
Copy link

tgruben commented Oct 18, 2024

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

@francisHugo
Copy link

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.

@Zachatoo
Copy link
Collaborator

@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.

@Zachatoo Zachatoo changed the title Templater broken ? Trigger Templater on new file creation does not replace Templater commands Oct 20, 2024
@tgruben
Copy link

tgruben commented Oct 21, 2024

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

@Zachatoo
Copy link
Collaborator

Zachatoo commented Oct 22, 2024

@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?

@tgruben
Copy link

tgruben commented Oct 22, 2024

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

@tgruben
Copy link

tgruben commented Oct 22, 2024

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

@M31nevel
Copy link

M31nevel commented Nov 1, 2024

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
Copy link

mmcc commented Nov 19, 2024

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.

@Harimus
Copy link

Harimus commented Dec 6, 2024

FYI I updated Obsidian to the latest (v1.7.7) and the templater + periodic notes issue was resolved. Seems like you have v1.7.6, so could be worth a try I'm not sure what in changelog fixed it

@Zachatoo
Copy link
Collaborator

Zachatoo commented Dec 6, 2024

Anyone else still having this issue after updating to the latest versions of both Obsidian and Templater? If so please provide repro steps and the error in the console, if applicable. Otherwise I'm going to close this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants