SilentVoid13/Templater

System Prompt in file order

AustrianPotatoLover opened this issue · 3 comments

Is your feature request related to a problem? Please describe.
Yes, I'm always frustrated when using the Templater plugin for Obsidian to create notes with multiple system prompts. Currently, when I structure my template to include multiple system prompts like this:

<% tp.system.prompt("Question 1") %>
<% tp.system.prompt("Question 2") %>
<% tp.system.prompt("Question 3") %>

The prompts are displayed in reverse order, starting with Question 3 and ending with Question 1. This is annoying when using it to promt me to fill something out, since almost always I want to think about the things at the start of the file first.

Describe the solution you'd like
I would like the Templater plugin to prompt the user in the order the prompts are written in the template. This means if I list Question 1 then Question 2 then Question 3. An option in the settings to toggle between "ascending" and "descending" order for the prompts might be ideal to accommodate different user preferences, but I don't know.

Describe alternatives you've considered
Currently I have some things in my frontmatter in reverse order and I am using dataview inline queries to then correct the order in the main file but it is far from ideal.

Okay I now found a solution myself. It woks when I query myself in one large block like this, so it is not a pressing issue. However, I find the behavior to still be a little counterintuitive.

Solution:

<%*  
let question1 = await tp.system.prompt("Question 1");
let question2 = await tp.system.prompt("Question 2");
%>

<% question1 %>
<% question2 %>

This will also work. The awaits were the key.

<% await tp.system.prompt("Question 1") %>
<% await tp.system.prompt("Question 2") %>
<% await tp.system.prompt("Question 3") %>

Oh, now I get it! Thanks so much, that's what I get from using some code I don't really understand😅