What I’m trying to do
I want to make an alias using Templater’s dynamic commands (<%+ ... %>
) with multiple parameters, but it doesn’t work well, as I will describe below.
Things I have tried
It works well when the command has only one argument. For example:
---
aliases: <%+ tp.date.now("YYYY-MM-DD") %>
---
(This example might look strange, but it is for an illustration purpose only)
Result (= what I see after switching to the reading mode):
However, it doesn’t work when it has multiple arguments. For example:
---
aliases: <%+ tp.date.now("YYYY-MM-DD", 1) %>
---
Result:
It looks like the parser recognizes the comma separating the arguments "YYYY-MM-DD"
and 1
as a delimiter separating two aliases. In other words, it appears to interpret the above YAML frontmatter as
---
aliases:
- <%+ tp.date.now("YYYY-MM-DD"
- 1) %>
---
I tried enclosing the whole command with quotes as below, but I’ve got the same result.
---
aliases: '<%+ tp.date.now("YYYY-MM-DD", 1) %>'
---
Result:
I also found that this problem doesn’t occur for non-reserved keys
(see here for the list of reserved keys).
For example:
---
key: <%+ tp.date.now("YYYY-MM-DD", 1) %>
---
Result:
So I suspect this problem is related to how Obsidian parses the alias metadata.
How can I fix this? Thank you.
Specs
- macOS Venture (version 13.2)
- Obsidian version 1.3.5
- Templater version 1.16.0