chhoumann / quickadd

QuickAdd for Obsidian
https://quickadd.obsidian.guide
MIT License
1.48k stars 135 forks source link

[BUG] Templater includes cause weird issues #608

Open android272 opened 9 months ago

android272 commented 9 months ago

Describe the bug I am using templates to create complex templates that are easier for me to edit and change things when needed. Templater allows you to write a line <% tp.file.include("[[Template 2]]") %> which will insert a second template at this line when templater creates new or the templater templater: replace Templates in the active file command is ran.

To Reproduce Steps to reproduce the behavior:

  1. With templater installed
  2. Create two templates:
# Header 1

<% tp.file.include("[[Template 2]]") %>

# Header 3
# Header 2
| Date / Time | Thought | Destruction | Talk Back |
  1. Create a capture quick add: File name: {{DATE:[Calendar/Journal]/YYYY/MM_MMM/YYYY-[W]ww}}.md Create file if it doesn't exist: true Create file with given template: Template 1 Insert after: # Header 2 Insert at end of section: true Consider subsections: true (Even though both templates don't have subsections) Capture format: | [[{{DATE:YYYY-MM-DD}}]] {{DATE:ddd}} | | | | | {{DATE:h:m}} | {{value}} | | |

  2. Run this quick add with any text for capture.

Expected behavior I expected new rows to be added at the end of the table in template 2 > Header 2

Screenshots This works if the file already exists. image

But if I am creating the file for the first time the capture format does not get inserted anywere in the file.

If I am creating the file for the first time, and I switch Consider subsections to false. Then the capture format is inserted in the middle of a different section for some reason. image

I think this is due to not allowing templater to create the template and run its templater: replace Templates in the active file command. If a file was created with template 1, and then the templater: replace Templates in the active file command was ran, before quick add tried to insert the capture into the file, then the header it is looking for would be in the file and things would run as smoothly as if the file was already created.

Desktop (please complete the following information):

Smartphone (please complete the following information):