Skip to content

Commit eb4eb1e

Browse files
np.Templating: add calendar targets for TemplateRunner
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 9683388 commit eb4eb1e

5 files changed

Lines changed: 664 additions & 9 deletions

File tree

‎np.Templating/CHANGELOG.md‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ See Plugin [Documentation](https://noteplan.co/templates/docs) for details on av
66

77
DBW: REMEMBER THAT IF YOU ADDED ANY HELPERS IMPORTS, ADD THEM TO THE HELPER MODULE TO GIVE SCRIPTS ACCESS TO THEM ALSO
88

9-
## [2.3.3] 2026-04-16 @dwertheimer
9+
## [2.4.0] 2026-04-16 @dwertheimer
10+
11+
### Added
12+
13+
- **TemplateRunner calendar targets:** `getNoteTitled` now treats rendered calendar dates (`YYYY-MM-DD`, `YYYY-MM`, `YYYY-Qn`, `YYYY`, including values rendered from tags like `<%- date.tomorrow('YYYY-MM-DD') %>`) as calendar notes, and supports `<tomorrow>` / `<yesterday>` / `<thismonth>` / `<nextmonth>` / `<thisquarter>` / `<nextquarter>` / `<thisyear>` / `<nextyear>` tokens alongside `<today>`.
1014

1115
### Fixed
1216

1317
- **Frontmatter booleans and zero:** `FrontmatterModule.parse` / `.attributes` no longer replace YAML **`false`** or numeric **`0`** with an empty string. That bug broke **`batchPrompts: false`** (and any other falsey-but-valid frontmatter), so consecutive `prompt` / `promptDate` still batched. Only **`null`** / **`undefined`** are coerced to `''` now.
1418

1519
### Edited in this release
1620

21+
- `np.Templating/src/NPTemplateRunner.js`, `np.Templating/__tests__/NPTemplateRunner.test.js`
1722
- `np.Templating/lib/support/modules/FrontmatterModule.js`, `np.Templating/__tests__/frontmatter-module.test.js`
18-
- `np.Templating/plugin.json` — version **2.3.3**
23+
- `np.Templating/plugin.json` — version **2.4.0**
1924

2025
## [2.3.2] 2026-04-14 @dwertheimer
2126

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
# Temporary Docs Handoff: TemplateRunner Calendar Targets
2+
3+
This temporary note summarizes the `np.Templating` 2.4.0 updates for documentation work. It can be removed after the public docs are updated.
4+
5+
## Summary
6+
7+
`TemplateRunner` frontmatter field `getNoteTitled` can now target calendar notes more directly.
8+
9+
Previously, `getNoteTitled` handled a few special targets such as `<today>`, `<thisweek>`, `<nextweek>`, `<current>`, `<choose>`, and `<select>`. Daily dates rendered from template tags, such as `2026-05-03`, could fall through to regular project-note title lookup.
10+
11+
Now, after template tags in `getNoteTitled` are rendered, valid calendar note titles route to calendar notes instead of regular note title lookup.
12+
13+
## Supported Calendar Title Formats
14+
15+
These rendered values are treated as calendar note targets:
16+
17+
- Daily: `YYYY-MM-DD`, for example `2026-05-03`
18+
- Monthly: `YYYY-MM`, for example `2026-06`
19+
- Quarterly: `YYYY-Qn`, for example `2026-Q3`
20+
- Yearly: `YYYY`, for example `2026`
21+
22+
Invalid date-shaped values are not treated as calendar notes. For example, `2024-99-99`, `2024-13`, and `2024-Q5` are rejected by strict validation and continue through the normal handling path.
23+
24+
## New Relative Tokens
25+
26+
`getNoteTitled` now supports these additional relative calendar tokens:
27+
28+
- `<tomorrow>`
29+
- `<yesterday>`
30+
- `<thismonth>`
31+
- `<nextmonth>`
32+
- `<thisquarter>`
33+
- `<nextquarter>`
34+
- `<thisyear>`
35+
- `<nextyear>`
36+
37+
Existing tokens remain supported:
38+
39+
- `<today>`
40+
- `<thisweek>`
41+
- `<nextweek>`
42+
- `<current>`
43+
- `<choose>`
44+
- `<select>`
45+
46+
## Examples
47+
48+
Write to tomorrow's daily note:
49+
50+
```yaml
51+
getNoteTitled: <tomorrow>
52+
```
53+
54+
Write to a date generated by a template expression:
55+
56+
```yaml
57+
getNoteTitled: <%- date.tomorrow('YYYY-MM-DD') %>
58+
```
59+
60+
Write to next month's monthly note:
61+
62+
```yaml
63+
getNoteTitled: <nextmonth>
64+
```
65+
66+
Write to a rendered monthly note title:
67+
68+
```yaml
69+
getNoteTitled: <%- date.now('YYYY-MM', '1m') %>
70+
```
71+
72+
Write to next quarter's quarterly note:
73+
74+
```yaml
75+
getNoteTitled: <nextquarter>
76+
```
77+
78+
Write to a rendered yearly note title:
79+
80+
```yaml
81+
getNoteTitled: 2026
82+
```
83+
84+
## Boundary Behavior
85+
86+
Relative tokens are calculated with calendar-aware date math:
87+
88+
- On `2024-12-31`, `<nextmonth>` resolves to `2025-01`.
89+
- On `2024-12-31`, `<nextquarter>` resolves to `2025-Q1`.
90+
- On `2024-12-31`, `<nextyear>` resolves to `2025`.
91+
92+
Month, quarter, and year notes use NotePlan calendar note formats (`YYYY-MM`, `YYYY-Qn`, `YYYY`) and open/write using the corresponding calendar timeframe.
93+
94+
## Documentation Notes
95+
96+
When documenting rendered template expressions, prefer explicit output formats:
97+
98+
```yaml
99+
getNoteTitled: <%- date.tomorrow('YYYY-MM-DD') %>
100+
```
101+
102+
Avoid relying on `date.tomorrow()` without a format when the target must be a calendar note, because the user's default templating date format may not be `YYYY-MM-DD`.
103+
# Temporary Docs Handoff: TemplateRunner Calendar Targets
104+
105+
This temporary note summarizes the `np.Templating` 2.4.0 updates for documentation work. It can be removed after the public docs are updated.
106+
107+
## Summary
108+
109+
`TemplateRunner` frontmatter field `getNoteTitled` can now target calendar notes more directly.
110+
111+
Previously, `getNoteTitled` handled a few special targets such as `<today>`, `<thisweek>`, `<nextweek>`, `<current>`, `<choose>`, and `<select>`. Daily dates rendered from template tags, such as `2026-05-03`, could fall through to regular project-note title lookup.
112+
113+
Now, after template tags in `getNoteTitled` are rendered, valid calendar note titles route to calendar notes instead of regular note title lookup.
114+
115+
## Supported Calendar Title Formats
116+
117+
These rendered values are treated as calendar note targets:
118+
119+
- Daily: `YYYY-MM-DD`, for example `2026-05-03`
120+
- Monthly: `YYYY-MM`, for example `2026-06`
121+
- Quarterly: `YYYY-Qn`, for example `2026-Q3`
122+
- Yearly: `YYYY`, for example `2026`
123+
124+
Invalid date-shaped values are not treated as calendar notes. For example, `2024-99-99`, `2024-13`, and `2024-Q5` are rejected by strict validation and continue through the normal handling path.
125+
126+
## New Relative Tokens
127+
128+
`getNoteTitled` now supports these additional relative calendar tokens:
129+
130+
- `<tomorrow>`
131+
- `<yesterday>`
132+
- `<thismonth>`
133+
- `<nextmonth>`
134+
- `<thisquarter>`
135+
- `<nextquarter>`
136+
- `<thisyear>`
137+
- `<nextyear>`
138+
139+
Existing tokens remain supported:
140+
141+
- `<today>`
142+
- `<thisweek>`
143+
- `<nextweek>`
144+
- `<current>`
145+
- `<choose>`
146+
- `<select>`
147+
148+
## Examples
149+
150+
Write to tomorrow's daily note:
151+
152+
```yaml
153+
getNoteTitled: <tomorrow>
154+
```
155+
156+
Write to a date generated by a template expression:
157+
158+
```yaml
159+
getNoteTitled: <%- date.tomorrow('YYYY-MM-DD') %>
160+
```
161+
162+
Write to next month's monthly note:
163+
164+
```yaml
165+
getNoteTitled: <nextmonth>
166+
```
167+
168+
Write to a rendered monthly note title:
169+
170+
```yaml
171+
getNoteTitled: <%- date.now('YYYY-MM', '1m') %>
172+
```
173+
174+
Write to next quarter's quarterly note:
175+
176+
```yaml
177+
getNoteTitled: <nextquarter>
178+
```
179+
180+
Write to a rendered yearly note title:
181+
182+
```yaml
183+
getNoteTitled: 2026
184+
```
185+
186+
## Boundary Behavior
187+
188+
Relative tokens are calculated with calendar-aware date math:
189+
190+
- On `2024-12-31`, `<nextmonth>` resolves to `2025-01`.
191+
- On `2024-12-31`, `<nextquarter>` resolves to `2025-Q1`.
192+
- On `2024-12-31`, `<nextyear>` resolves to `2025`.
193+
194+
Month, quarter, and year notes use NotePlan calendar note formats (`YYYY-MM`, `YYYY-Qn`, `YYYY`) and open/write using the corresponding calendar timeframe.
195+
196+
## Documentation Notes
197+
198+
When documenting rendered template expressions, prefer explicit output formats:
199+
200+
```yaml
201+
getNoteTitled: <%- date.tomorrow('YYYY-MM-DD') %>
202+
```
203+
204+
Avoid relying on `date.tomorrow()` without a format when the target must be a calendar note, because the user's default templating date format may not be `YYYY-MM-DD`.

0 commit comments

Comments
 (0)