From d422079b13b40bec4dfdc6bce5cf595d33ed6cfa Mon Sep 17 00:00:00 2001 From: Gamosoft Date: Tue, 16 Dec 2025 16:13:24 +0100 Subject: [PATCH] added extra placeholders --- backend/utils.py | 18 ++++++++++++------ documentation/API.md | 3 +++ documentation/FEATURES.md | 3 +++ documentation/TEMPLATES.md | 3 +++ frontend/index.html | 3 +++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/backend/utils.py b/backend/utils.py index 34f46a0..f978f1c 100644 --- a/backend/utils.py +++ b/backend/utils.py @@ -773,12 +773,15 @@ def apply_template_placeholders(content: str, note_path: str) -> str: Replace template placeholders with actual values. Supported placeholders: - {{date}} - Current date (YYYY-MM-DD) - {{time}} - Current time (HH:MM:SS) - {{datetime}} - Current datetime (YYYY-MM-DD HH:MM:SS) - {{timestamp}} - Unix timestamp - {{title}} - Note name without extension - {{folder}} - Parent folder name + {{date}} - Current date (YYYY-MM-DD) + {{time}} - Current time (HH:MM:SS) + {{datetime}} - Current datetime (YYYY-MM-DD HH:MM:SS) + {{timestamp}} - Unix timestamp + {{year}} - Current year (YYYY) + {{month}} - Current month (MM) + {{day}} - Current day (DD) + {{title}} - Note name without extension + {{folder}} - Parent folder name Args: content: Template content with placeholders @@ -795,6 +798,9 @@ def apply_template_placeholders(content: str, note_path: str) -> str: '{{time}}': now.strftime('%H:%M:%S'), '{{datetime}}': now.strftime('%Y-%m-%d %H:%M:%S'), '{{timestamp}}': str(int(now.timestamp())), + '{{year}}': now.strftime('%Y'), + '{{month}}': now.strftime('%m'), + '{{day}}': now.strftime('%d'), '{{title}}': note.stem, '{{folder}}': note.parent.name if str(note.parent) != '.' else 'Root', } diff --git a/documentation/API.md b/documentation/API.md index f570533..adde9a3 100644 --- a/documentation/API.md +++ b/documentation/API.md @@ -412,6 +412,9 @@ Creates a new note from a template with placeholder replacement. - `{{time}}` - Current time (HH:MM:SS) - `{{datetime}}` - Current datetime - `{{timestamp}}` - Unix timestamp +- `{{year}}` - Current year (YYYY) +- `{{month}}` - Current month (MM) +- `{{day}}` - Current day (DD) - `{{title}}` - Note name without extension - `{{folder}}` - Parent folder name diff --git a/documentation/FEATURES.md b/documentation/FEATURES.md index 10ad475..62025b4 100644 --- a/documentation/FEATURES.md +++ b/documentation/FEATURES.md @@ -226,6 +226,9 @@ Create notes from reusable templates with dynamic placeholder replacement. - `{{time}}` - Current time (HH:MM:SS) - `{{datetime}}` - Current date and time - `{{timestamp}}` - Unix timestamp +- `{{year}}` - Current year (YYYY) +- `{{month}}` - Current month (MM) +- `{{day}}` - Current day (DD) - `{{title}}` - Note name (without extension) - `{{folder}}` - Parent folder name diff --git a/documentation/TEMPLATES.md b/documentation/TEMPLATES.md index fb88c5a..e6db71d 100644 --- a/documentation/TEMPLATES.md +++ b/documentation/TEMPLATES.md @@ -40,6 +40,9 @@ Templates support dynamic placeholders that are replaced when you create a note: | `{{time}}` | Current time | `14:30:45` | | `{{datetime}}` | Current date and time | `2025-11-26 14:30:45` | | `{{timestamp}}` | Unix timestamp | `1732632645` | +| `{{year}}` | Current year | `2025` | +| `{{month}}` | Current month | `11` | +| `{{day}}` | Current day | `26` | | `{{title}}` | Note name (without .md) | `Weekly Meeting` | | `{{folder}}` | Parent folder name | `Projects` | diff --git a/frontend/index.html b/frontend/index.html index 3b88d5e..03b5a91 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -2547,6 +2547,9 @@ {{date}}, {{time}}, {{datetime}}, + {{year}}, + {{month}}, + {{day}}, {{title}}, {{folder}}