First of all, you have to use the <%* ... %> tags with the star after the first tag to allow JS execution. So having this template:
<%* console.log("hello world") %>
…you now have to execute your Templater code using the hotkey you assigned to it (or the “Replace templates in the active file” Obsidian command), then it’ll vanish and your DevTools Inspector console will show the message. Just tested it and the message shows up in a heartbeat.
…Perhaps I should have formulated my questions more clearly. I outlined my use case for the templater script in this forum post:
My question mainly focuses on how to view the console output in the terminal…
Let’s consider this simple example: I have a note titled “templater test” containing only one line of code:
<%* console.log("hello world") %>
Then, I execute this templater script titled “templater test” within another note using the command “Open insert template modal.”
Where and how can I see the console output of “hello world”? I’ve only been able to see this (apologies, as I don’t have much experience using these development tools):
My setup when testing templates that I’ve got a file called xTemplate which is linked to Cmd + Ctrl + x. This template I then execute multiple times when testing in some log file.
If I add your code into this xTemplate file, and hit the hot key combination it shows as follows in the same place as from your screenshot:
If it doesn’t show there, then you’ve got something else disturbing the process. Like possibly something else causing Templater to bail out before reaching your debug statement. Note that this could be a failing Templater user script function.
But in general you should see the output in the window as you described, so it’s kind of strange that you don’t see it there.
after jumping around in my vault, open some other notes, writing and so on, I constantly get new messages of the same typ…
… what is also strange: the templater plugin works usually in my setup. For example this code will be executed without errors (still I’ve got formating issues, but the script is executed correctly):
Do these error messages indicate, that there is something generally wrong in my Obsidian?
Try creating a new empty vault, install just the Templater plugin and see what happens then. If that works you’ve got some issue most likely with another plugin. If it doesn’t work, then either you’re doing something strange or there is something with your Obsidian installation.
What version of Obsidian and Templater are you on?
I disabled all my plugins and themes in my main vault and tried it: nothing, no console log…
I have the newest installer, see debug info:
SYSTEM INFO:
Obsidian version: v1.5.0
Installer version: v1.4.13
Operating system: Windows 10 Pro 10.0.22621
Login status: logged in
Catalyst license: insider
Insider build toggle: on
Live preview: on
Base theme: dark
Community theme: none
Snippets enabled: 2
Restricted mode: off
Plugins installed: 60
Plugins enabled: 1
1: Templater v1.18.1