Grab the first three letters from {{title}}?

I’m trying to setup a template that fills in a yaml tag field with the first three letters of the note title. I’ve been looking through templater docs and I feel like there’s probably a way to do this but I can’t seem to find an example. Any ideas?

Thanks
Tom

Things I have tried

What I’m trying to do

Ok, I’ve got something that works. but I’d love to know if there’s a different way to do this a little cleaner:

tag: [ <% tp.file.title[0]+tp.file.title[1]+tp.file.title[2] %> ]

You can use the javascript slice method:

<% tp.file.title.slice(0,3) %>

2 Likes

Thanks so much for the reply! I KNEW there had to be a cleaner way of doing this.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.