How can i handle obsidian templater const problem

What I’m trying to do

Hi All.

I’m using templater’s Javascript Execution Command and there’s a problem that I can’t solve. Here’s what I wrote.

company: <% await tp.system.prompt("company's name") %>
title: <% await tp.system.prompt("title") %>
const execution_value = await tp.system.suggester(["author", "journalist"],["author", "journalist"]) 
class: <%* tR += execution_value %>
<%* if (tR += execution_value == "author") { -%> 
<%* } else { -%> 
<%* } -%>
url: <% await tp.system.prompt("URL") %>

I chose “journalist” and the result is below


it showed the result of the excution(false) and also showed incorrect result value

Things I have tried

Before I wrote this i’d checked the templater manual
the code in example chapter

tR + execution_value i tried that but it didn’t work and still showed wrong value.

Replace <%* tR += execution_value %> with <% execution_value %> and tR += execution_value == "author" with execution_value === "author".

tR += is for appending text to your file.

thank you!

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