-
-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Please fill out these Check-boxes
- I checked for existing similar issues
- I checked that the plugin is up to date
- The issue persists with all other plugins and themes disabled
Plugin Version
1.3.4
This Issue Occurs on
- Windows
- Linux
- macOS
- Android
- iOS
Debug Info
SYSTEM INFO:
Obsidian version: v1.8.7
Installer version: v1.8.4
Operating system: Windows 10 Home 10.0.19045
Login status: not logged in
Language: en
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: off
Plugins installed: 4
Plugins enabled: 4
1: Meta Bind v1.3.4
2: JS Engine v0.3.1
3: Dataview v0.5.67
4: Templater v2.10.0
RECOMMENDATIONS:
Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.
Describe the Issue
When using a button to run the "Run Templater File" action, templates break or pull incorrect information. For example, when using this action all references to the current file use the template's file and not the note the button is present in. Sometimes the template just errors as well. This behavior does not occur if you run the exact same template file via a command action instead.
Here's a simple example that prints the file title and logs the current file's tfile in the console:
The templater script, in a file named "Log tFile.md"
<%*
tR = ''; // this line makes templater ignore the frontmatter of this template file
const tfile = tp.file.find_tfile(tp.file.title);
console.log("Current tfile")
console.log(tfile)
-%>
<% tp.file.title %>
When inserted into a note named "You Remind Me Of The Button.md" via the templater modal or using the hotkey/command for that template or using a meta bind button using the command action the console logs the tfile for "You Remind Me Of The Button.md" and prints the file title at the cursor. All is well.


Here's the button using the command action:
```meta-bind-button
label: Log tFile - command
icon: ""
style: default
class: ""
cssStyle: ""
backgroundImage: ""
tooltip: ""
id: ""
hidden: false
actions:
- type: command
command: templater-obsidian:Testing Templater/Log tFile.md
```
However, if you instead run that script by using a button with the "Run Templater File" action, the tfile for "Log tFile.md" is logged into the console instead and absolutely nothing is printed in the note.

Here's the button using run template file action:
```meta-bind-button
label: Log tFile - runtemplaterfile
icon: ""
style: default
class: ""
cssStyle: ""
backgroundImage: ""
tooltip: ""
id: ""
hidden: false
actions:
- type: runTemplaterFile
templateFile: Testing Templater/Log tFile.md
```
I've also had templates entirely fail and error. I had this error occur when running a template file in my vault that works perfectly when using the same file as a command action instead of run templater file.

Steps to Reproduce
- add Templater to the metabind example vault
- set templates folder in templater settings
- add the tfile logging script in post to your templates folder
- add that template as a template to add a hotkey for in templater settings
- create a new note
- add a button that triggers the tfile logging script using the command action
- add a button that triggers the tfile logging script using the run templater file action
- click both buttons
Expected Behavior
I would expect command > insert template file and run templater file to work identically and that the run templater file action would be compatible with all templates that otherwise work when used by inserting via templater or hotkey etc.