Undesired replacement of template variable

My use case might be very specific - I haven’t found any corresponding information in the knowledge base, at least. Unless I’m doing something wrong, this might be unwanted behaviour or a bug of the Templates Core Plugin.

I’m not using the community plugin Templater, only the Templates Core Plugin, the limited variables are enough for my specific use case. The frontmatter for each of my templates looks approx. like this:

(template file: 06.111 Casting.md)
---
created: {{date}}
updated: {{date}}
template: "[[06.111 Casting]]"
---
# {{title}}

This way, whenever I apply a template to a new note, a link to the template is maintained in the frontmatter. Consequently, all new notes have access to the notes that refer to the template. That works as expected. When I change the name of the template. All links refering to the template, including the link inside the template itself, are updated correctly.

The only problem I have, however, is that for some reason with any change of the template file name, all variables in its frontmatter are converted into strings. Variables outside of the frontmatter remain untouched:

---
created:
  "{ date }":
updated:
  "{ date }":
template: "[[06.222 Casting]]"
---
# {{title}}

It makes no difference, if I add date-formats to the code, the variables are converted into strings anyway:

---
created:
  "{ date:YYYY-MM-DD }":
updated:
  "{ date:YYYY-MM-DD }":
template: "[[06.103 Casting]]"
---
# {{title}}

Is there anything I can do to prevent this and maintain the template variables as variables after any file name change, or should this be filed as a bug/unwanted behaviour?

This is potentially due to the fact that templates (for the Templates core plugin) needs to be edited in Source mode (otherwise, they kind of get “broken” by Properties in Live Preview) :backhand_index_pointing_down: :blush:

What Pch said above.

Updated help docs. Woop, Woop →

https://obsidian.md/help/plugins/templates#Create+a+template


You can also quote the template variables in the YAML to avoid the metadata editor corrupting them if you do use it after initially creating the template.

---
created: "{{date}}"
updated: "{{date}}"
template: "[[06.111 Casting]]"
---
# {{title}}

I am not using live preview, only source mode to edit templates, as you can see in the gif. However, adding the quotes around the variables did solve the issue! Thank you very much, Ariehen!
Template Variables

That’s a new one I haven’t seen before. I thought it only happened when using the metadata editor with unquoted template variables.

Obsidian_ZsmjNv8KNs

I assume because of the link updating, processFrontMatter is kicking in.

Quotes for the win!