First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.
What I’m trying to do
I am new to javascript, and would love some help coding If-Then scenarios while utilizing the suggester function and calling appropriate templates. I know…it’s a lot.
I write reviews of bars and restaurants. Each bar/restaurant has its own master file within either the Bar folder or Restaurant folder that contains its name, the owner and the city.
When it’s time to write a review my goal is to:
- Respond to a prompt: Bar or Restaurant
- If Bar, see all files within the Bar folder so I can choose the appropriate business and likewise for Restaurants
- Have the system pull up the relevant template (BarReview / RestaurantReview), and finally
- Have the new template pull in data from the businesses’ master file - such as Chef, Owner, etc.
OK. That’s a lot. If anyone is willing to help out, I believe others might find this info useful as well. Thanks !!!
The Bar Template looks like:
<% reviewType %> Review
<% dateValue %>
<% barName %>
Their best drink is: <% bestDrink %>
Chef: I don’t know how to reference the Bar Master file here (though know to put “.Chef” after bracketed name to pull metadata)
Owner: SAME HERE
Notes:
Things I have tried
<%*
let dateValue = tp.date.now()
let reviewType = await tp.system.suggester(["Bar", "Restaurant"], ["Bar", "Restaurant"])
if (reviewType == "Bar") {
let barName = await tp.system.suggester((item) => item.basename, app.vault.getMarkdownFiles().filter(file => file.path.startsWith("Bar Folder")
let bestDrink = await tp.system.prompt("What is best drink?");
} else {
let restaurantName = await tp.system.suggester((item) => item.basename, app.vault.getMarkdownFiles().filter(file => file.path.startsWith("Restaurant Folder")
let bestMeal = await tp.system.prompt("What is best meal?");
}
-%>
Sadly - this isn't working at all....