JavaSript in Obsidian

Hello everyone,
it seems I have either disabled a crucial switch or haven’t found it yet.
In any case, Javascript commands don’t seem to run in my Obsidian.
Simple example: “<%*tp.file.title%>” stays like this, regardless of whether I’m in editor view, reading view or live preview. When I put the string in my template for new files, this string stays a code-string.
I can’t find anything about this with Google or here in the forum. Apparently this is so basic that it isn’t covered?

These aren’t javascript commands, but Templater commands. Do you have the Templater community plugin installed and enabled? Also, you should note that by default, these don’t execute unless you create a template based note using Templater. You can use the command “Replace templates in active file” to trigger Templater. Alternatively, you can set the Templater setting “Trigger on new file creation” to have Templater execute and replace templates in all new files.

1 Like

Thank you for the prompt reply. Yes, I have installed and activated the Templater plugin. I also have this string in a template file. But when I use the template - whether as a file template (new file) or as a text module - the string remains as it is and the variable is not replaced by the value.

How do I do this? Where do I find this command?

O.K., I had some mistake in another Templater command, which caused an error. After deleting it out of the New-file-template, now the command <%tp.file.title%> does what it should by creating a new file with a templater shortcut. But this command you mentioned “Replace templates in active file” I don’t find in the Configuration of the Plugin nor in the menue or elsewhere. :frowning:

And the filename of the new file is of course a placeholder. So - if I change the file name first or later when editing the file - how do I make Templater change the value of the variable (again)?

Edit: Once executed the Variable doesn’t exist anymore. So it’s clear, that only with this variable I can’t receive what I want. But how do you solve the wanted automatism, that by creating a new file (and when the filename later ist changed) the filename and the first heading the file name is automatically updated?

O.K. found :slightly_smiling_face:
CMD+P / type: “templater:Replace …” and so on, or just OPT+R.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.