Edit Templater user scripts within Obsidian?

Things I have tried

Added a folder MaDo/TemplaterScripts and configured it in Templater → Options. Added some user scripts into this folders, but Templater says “No user scripts found”, which turns out to be because my script file got the secondary extension of .md

Tried installing Custom File extension plugin by MeepTech

Failed miserably. :cry: The plugin wasn’t found in the community browser, and when I tried bluntly to copy it into the plugin folder, it failed loading. Not quite ready for installing, it seems.

Installed Plaintext for Obsidian

This kind of works, it seems after adding js as an extension. However, I’m not able to make new files with just the .js extension. So some tinkering in the command prompt is still needed, alas.

So I then renamed my script file, outside of Obsidian, and of course it disappeared within the file explorer of Obsidian. But now it appears as a proper user script function.

What I’m trying to do

I would love for the opportunity to (create and) edit my javascript files from within Obsidian, but not sure if that is possible, and if so how? Can I place the scripts folder somewhere special to allow for this to happen, or is this just a no-go?

Regards,
Holroy

While you can do it, it’s a lot more fun (and free) to use VSCode instead. That way you get full syntax highlighting, code completion, hinting, linting, all the bells and whistles.

You can “Open Folder” within VSCode, and have your whole Obsidian vault and file structure all there inside the file explorer.

I’m a coder by profession, so I’m well familiar with VS Code, but I’m not very keen on changing programs all the time, so if possible I would love to do it within Obsidian.

Although it’s a bit of a pain to debug stuff using Templater (and trying to call dataviewjs stuff at the same time)

So after some further testing, and sadly not too much response in this thread, I found that using Plaintext for Obsidian, is doing the trick for now. I’m missing a proper syntax highlighting directly from the plugin, but I’ve commented on a feature request regarding that, so hopefully it’ll come.

In the meantime, I found a solution using Templater and Buttons, see my own thread on Raw embed of javascript into a code block, to get syntax highlighting of any given script.

The main downside to this solution, is two-folded:

  1. In order to introduce new javascript files, I need to create the javascript files outside of Obsidian (or at least change the extension from .md to .js)
  2. My syntax highlight is not automatic, so after changes, I need to hit a button again.
1 Like

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