Help with using the Templater community plugin

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") %>
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.last_modified_date(format: string = "YYYY-MM-DD HH:mm"));
let _rst = await Promise.all(_prs);
tR+='---\ncreation date: '
tR+='\nmodification date: '
tR+='\nalias: \ntags: '
tR+='\n---\n\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://, <anonymous>:277:15)
    at compile (eval at <anonymous> (app://, <anonymous>:840:19)
    at handleCache (eval at <anonymous> (app://, <anonymous>:1083:68)
    at eval (eval at <anonymous> (app://, <anonymous>:1129:33)
    at new Promise (<anonymous>)
    at render (eval at <anonymous> (app://, <anonymous>:1127:24)
    at renderAsync (eval at <anonymous> (app://, <anonymous>:1161:12)
    at TemplateParser.eval (eval at <anonymous> (app://, <anonymous>:1712:34)
    at (<anonymous>)
    at eval (eval at <anonymous> (app://, <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!

Unfortunately, I am not able to answer your question. I thought perhaps you might be able to help me with a question about Templater.

I feel as though I am missing something. I have reviewed the documentation, but I am still not able to run and get a basic template to show any output.

I’m certain my issue is something simple, but I’m just not able to find the issue. Any suggestions, would be appreciated.

Today: <%“dddd Do MMMM YYYY, ddd”) %>

Hi @Cajun, I’m not sure if this will help, but one of the things that I misunderstood with using Templater is that the codedoesn’t auto-update. When I applied a template e.g. when creating a new note it worked just fine. The Data View plugin does update fields. How do you use the code you posted?

Thank you for your response. What I was trying to do is get the date information to show up automatically when I open a new daily note. As of now I am copying the date from the Daily Note file name. I don’t think it should be difficult, but so far I have not been successful using the Templater.

Cajun here are some of the templates I use.

Date Created template → output is 2020-01-31:


Date from Title (title has YYYYMMDD format) → output is 2020-01-31

<“YYYY-MM-DD”, 0, tp.file.title, “YYYYMMDD”)%>

Date from Title Long (title includes YYYYMMDD format) → output is Monday December 31 2021

<“dddd MMMM DD YYYY”, 0, tp.file.title, “YYYYMMDD”)%>

I have these templates in my Diary Template and in my New Note template. Whenever I create a new note, I just press Alt-E and select the “New Note” template. (In the case of a new Diary note though it’s done automatically when I select the calender that comes with the Daily Notes plugin)


@Lise thank you, I will give this a try. I appreciate the information.

This is my template I use for a weekly note review.

This is how it looks after I create a new note. There is an option to trigger Templater on new file creation. That is what I use for the template to work. There is also a Templater option in the sidebar to add a template to a note. It will convert the templates if they are typed correctly.