Templater: replacing " " with "_"

Things I have tried

I’ve tried using multiple variations of

<% tp.system.clipboard.replace(/ /g, “_”) %>

but that doesn’t work. I’m assuming it’s just a basic misunderstanding of the syntax since I don’t code a whole lot, but any help would be appreciated!

What I’m trying to do

I’m trying to automatically fill in a url with a string that will already be on my clipboard when I call the template. I also might end up using a prompt though depending on how the workflow feels.

A couple of things missing:

First, clipboard is a function, so you need to execute that function with a () after the function name: clipboard().

Second, the function is asynchronous, so you need to await the result before using replace on it:

<% (await tp.system.clipboard()).replace(/ /g, '_') %>

Thank you so much. Yeah I knew it didn’t feel right to put that after the function itself, but I didn’t really know what else to try. Thanks again!

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