Closed ONLYA closed 5 months ago
The template buttons should run Templater commands. So in theory you could insert a "template" that runs a prompt and then inserts the text into the current note:
<%* const prompt = tp.system.prompt("what's up?") %> <% prompt %>
type append template action prompt template note
You could also add the templater prompt into the button itself and use
templater true
to run it on click.
I'm not sure I understand your first idea..
Thanks for your reply.
I found the command tp.system.prompt("what's up?")
will run at first, turn the input into a static field and never ask a prompt for the next click again. I may need to workaround to find out a method to do it. (I am using it with Dataview. What I am trying to do is to make an "Add new" button so that I don't have to create a new file and apply a template into it manually.)
As for the first idea: let's say we have got a template file whose content is:
---
date: <% tp.date.now("HH:MM") %>
---
# Timeline
Its filename is assumed to be TEMPLATE New Timeline.md
.
Then inside another file, we have a button like:
name Add new
type note(TEST abcdefg, split) template
action TEMPLATE New Timeline
templater true
When I click it, it will generate a file with the content of:
---
date: <% tp.date.now("HH:MM") %>
---
# Timeline
As you can see, the template command is not called during the creation of the new file.
And the behaviour of the following block code:
name Add new
type note(<% tp.system.prompt("what's up?") %>, split) template
action TEMPLATE New Timeline
templater true
will generate an error message There was an error! Maybe the file already exists?
while it eventually works properly.
Or I can use HTML with javascript inside templater to achieve that. Like this:
Name: <input type="text" id="fname" name="fname">
```button
name Add new
type note(<% document.getElementById("fname").value %>, split) template
action TEMPLATE New Timeline
templater true
```
I just need to enable a setting within the Templater's configurations to make it render the command. I still find it a bit buggy with user script but I believe it is on Templater's side.
This is a good plugin and I like it. I think that this needs more features to make it a more useful plugin. There are 2 suggestions.
Those are my suggestions. I can see great potential from this plugin to be used with Dataview and Templater. I hope that this plugin will make Obsidian note-taking a more user-friendly process with an easy UI like Notion.