Obsidian - Buttons with Templater (Patreon)
Content
If you like buttons and would like to add a button that creates a note that comes with a template then that's the purpose of this video. It shows you how to use the Buttons and Templater plugins in collaboration to quickly create new notes that will:
- prompt you for the note name
- move the note to a specified folder
- apply a specified template to the note
It's a great way to create new notes when in the middle of game.
Template Code
<% tp.file.title %>
<% await tp.file.move("/2. Mechanics/Non-Player Characters/" + tp.file.title) %>
<%*
const hasTitle = !tp.file.title.startsWith("NewNPC");
let title;
if (!hasTitle) {
title = await tp.system.prompt("Enter NPC Name");
await tp.file.rename(title);
} else {
title = tp.file.title;
}
_%>
<% tp.file.cursor() %>
Button Code
```button
name New NPC
type note(NewNPC, split) template
action TemplateNPC
templater true
```
^button-NewNPCID
Files
Previews only