What I’m trying to do
I’m trying to create a Templater script that uses the start dates created by the Journals plugin when generating a new weekly report. I.e. I’ve got Journals creating a value called week-start-date, and I’d like Templater to create headings with a date for each day of the week using code like weekStart.clone().add(1, ‘days’).format(‘DD-MM-YYYY’). However it looks like the week-start-date isn’t being calculated before Templater tries to kick in and I can’t work it out.
Things I have tried
Claude has helped me get my template started with (so there may be unnecessary code, any help appreciated):
<%*
// Access the date objects that Journals plugin creates
let weekStartDate = await tp.frontmatter[‘week-start-date’];
let weekEndDate = await tp.frontmatter[‘week-end-date’];
// Convert date objects to moment objects
const weekStart = await moment(weekStartDate);
const weekEnd = await moment(weekEndDate);
// Format dates for use in template
const startDate = weekStart.format(‘YYYY-MM-DD’);
const endDate = weekEnd.format(‘YYYY-MM-DD’);
_%>
Monday weekStart.format(‘DD-MM-YYYY’)
Tuesday weekStart.clone().add(1, ‘days’).format(‘DD-MM-YYYY’)
etc