I’d like to user Templater and Buttons to auto-populate inline metadata Foo:: in a new file, based on criteria from the present file. For example, if I’m in File A.md, I want a templater script or a button that can:
Create a new File B.md based on template Template 1.md
Find Foo:: in the new File B.md and change it to Foo:: File A
Note: I know that Buttons can replace a specific line in an file, and I could have it replace the specific line # that contains Foo::, but I’d prefer to run javascript to search and replace for Foo:: in case I change the template and it’s on a different line#.
What I’ve tried:
As an initial step I wanted to see if I could pass a variable from a button to a templater codeblock in a template. If that worked, I could use that variable along with javascript in a templater codeblock to search and replace Foo::. But passing a variable like below did not work:
In File A.md, this button:
name Make an Hourly Note
type note(<%* let foo = tp.file.title%>) template
action Template
templater true
I don’t know how to do this with templater. I use Note Refactor (community plugin) which lets you set a template in the settings. When I write something in a note, I can decide to split it into a new note and include information from the current file in it by setting up the template for it.
Thanks. What I’m going for is a programmatic approach—the new note should include for example the title of the current note as the value of inline metadata Foo::. Is that possible with Note Refactor?
Thanks. It looks like Note Refactor has only a single template. I would be using this with multiple types of notes and templates, so it looks like some kind of solution with Templater would be better.