I’d approach the template in the following manner:
<%*
const sun = tp.date.now('ddd',0,'2023-02-05','YYYY-MM-DD');
const mon = tp.date.now('ddd',0,'2023-02-06','YYYY-MM-DD');
const tue = tp.date.now('ddd',0,'2023-02-07','YYYY-MM-DD');
const wed = tp.date.now('ddd',0,'2023-02-08','YYYY-MM-DD');
const thu = tp.date.now('ddd',0,'2023-02-09','YYYY-MM-DD');
const fri = tp.date.now('ddd',0,'2023-02-10','YYYY-MM-DD');
const sat = tp.date.now('ddd',0,'2023-02-11','YYYY-MM-DD');
const day = tp.date.now('ddd',0,tp.file.title,'YYYY-MM-DD');
//Example: Every Tuesday
if (day === tue)
{
tR += '- [ ] a\n';
}
//Example: Every weekday
if (day === mon || day === tue || day === wed || day === thu || day === fri)
{
tR += '- [ ] b\n';
tR += '- [ ] c\n';
}
//Example: Every Tuesday and Thursday
if (day === tue || day === thu)
{
tR += '- [ ] d\n';
}
-%>
- [ ] e (happens every day)
Basically, this template computes the local abbreviation for each day of the week so I don’t have to worry whether the week starts on Sunday or Monday. You can then use these constants to compare against the day-of-the-week of the note’s filename. I append to the Templater global variable tR
the tasks that should be output for a given day. Be sure that each one ends with \n
to return to the next line. Any tasks that occur everyday are listed outside the Templater script.
I find this style a lot more readable and flexible than trying to intersperse content and code.
Running this template on a note with today’s date (2023-02-07 which is a Tuesday) results in the following output:
- [ ] a
- [ ] b
- [ ] c
- [ ] d
- [ ] e (happens every day)
For one with tomorrow’s date (2023-02-08 which is a Wednesday), I get:
- [ ] b
- [ ] c
- [ ] e (happens every day)