My problem comes next. I want the script to include another templater script based on the category. That script would ask me to select from a list of subcategories. Here’s some pseudocode:
if categories contains "apps"
tp.file.include("yaml-choose-app")
else if categories contains "books"
tp.file.include("yaml-choose-books)
else etc.
I have created a number of include files that work fine. But I don’t know how to write the if-statement.
I would really appreciate any help you folks can give me.
BTW, I’ve taken kepano’s advice to heart and used plural property names and list types as much as possible.
Hi, I can’t test anything right now, but might something like this help?
You have to create it in a .js file though and call it with <% tp.user.xxx(tp) %>
When do you call this script? At the creation of a new note? After creating a new note and filling in the categories?
You can also execute javascript code within the template itself, without going through a separate javascript file, by using the javascript blocks, <%* ... %>. Although something like this could be a user function within Templater.
After choosing the sub-categories, what kind of templates do you then want to insert? Just frontmatter stuff or full blown note templates?
There has recently been a few threads related to “meta template picker” which might do some of what you want, but to give precise answer we need a little more details as I’ve asked for above. That would help us give you precise answers.