I’m trying to create a default note template with Templater plugin.
I’ve set up the following in a file in a Templates folder.
---
creation date: <% tp.file.creation_date() %>
modification date: <% tp.file.last_modified_date(format: string = "YYYY-MM-DD HH:mm") %>
alias:
tags: <% tp.file.tags %>
---
# <% tp.file.title %>
When I create a new file with this I get the following error.
(unknown) Template parsing error, aborting. Eta Error: Bad template syntax
missing ) after argument list
=============================
var tR='',__l,__lP,include=E.include.bind(E),includeFile=E.includeFile.bind(E)
function layout(p,d){__l=p;__lP=d}
let _prs = [];
_prs.push(tp.file.creation_date());
_prs.push(tp.file.last_modified_date(format: string = "YYYY-MM-DD HH:mm"));
_prs.push(tp.file.tags);
_prs.push(tp.file.title);
let _rst = await Promise.all(_prs);
tR+='---\ncreation date: '
tR+=_rst[0]
tR+='\nmodification date: '
tR+=_rst[1]
tR+='\nalias: \ntags: '
tR+=_rst[2]
tR+='\n---\n\n# '
tR+=_rst[3]
tR+='\n'
if(__l)tR=await includeFile(__l,Object.assign(tp,{body:tR},__lP))
if(cb){cb(null,tR)} return tR
at EtaErr (eval at <anonymous> (app://obsidian.md/app.js:1:1151979), <anonymous>:277:15)
at compile (eval at <anonymous> (app://obsidian.md/app.js:1:1151979), <anonymous>:840:19)
at handleCache (eval at <anonymous> (app://obsidian.md/app.js:1:1151979), <anonymous>:1083:68)
at eval (eval at <anonymous> (app://obsidian.md/app.js:1:1151979), <anonymous>:1129:33)
at new Promise (<anonymous>)
at render (eval at <anonymous> (app://obsidian.md/app.js:1:1151979), <anonymous>:1127:24)
at renderAsync (eval at <anonymous> (app://obsidian.md/app.js:1:1151979), <anonymous>:1161:12)
at TemplateParser.eval (eval at <anonymous> (app://obsidian.md/app.js:1:1151979), <anonymous>:1712:34)
at Generator.next (<anonymous>)
at eval (eval at <anonymous> (app://obsidian.md/app.js:1:1151979), <anonymous>:52:71)
What I hope to achieve is that I can create new files with this template and after I’ve added more information to the note run it with a
Templater: Replace templates in the active file
command. I hope that then the modifcation date will be replaced and the tags with tags that I entered in the note.
Maybe I’m misunderstanding how updating the output of a template works after it has been used to create a note.
Any help will be greatly appreciated!