Merge pull request #106 from gamosoft/features/additional-placeholders
as suggested by @brouberol in #100 adds new template placeholders: year month day
This commit is contained in:
commit
d44abdda72
|
|
@ -773,12 +773,15 @@ def apply_template_placeholders(content: str, note_path: str) -> str:
|
||||||
Replace template placeholders with actual values.
|
Replace template placeholders with actual values.
|
||||||
|
|
||||||
Supported placeholders:
|
Supported placeholders:
|
||||||
{{date}} - Current date (YYYY-MM-DD)
|
{{date}} - Current date (YYYY-MM-DD)
|
||||||
{{time}} - Current time (HH:MM:SS)
|
{{time}} - Current time (HH:MM:SS)
|
||||||
{{datetime}} - Current datetime (YYYY-MM-DD HH:MM:SS)
|
{{datetime}} - Current datetime (YYYY-MM-DD HH:MM:SS)
|
||||||
{{timestamp}} - Unix timestamp
|
{{timestamp}} - Unix timestamp
|
||||||
{{title}} - Note name without extension
|
{{year}} - Current year (YYYY)
|
||||||
{{folder}} - Parent folder name
|
{{month}} - Current month (MM)
|
||||||
|
{{day}} - Current day (DD)
|
||||||
|
{{title}} - Note name without extension
|
||||||
|
{{folder}} - Parent folder name
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
content: Template content with placeholders
|
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'),
|
'{{time}}': now.strftime('%H:%M:%S'),
|
||||||
'{{datetime}}': now.strftime('%Y-%m-%d %H:%M:%S'),
|
'{{datetime}}': now.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
'{{timestamp}}': str(int(now.timestamp())),
|
'{{timestamp}}': str(int(now.timestamp())),
|
||||||
|
'{{year}}': now.strftime('%Y'),
|
||||||
|
'{{month}}': now.strftime('%m'),
|
||||||
|
'{{day}}': now.strftime('%d'),
|
||||||
'{{title}}': note.stem,
|
'{{title}}': note.stem,
|
||||||
'{{folder}}': note.parent.name if str(note.parent) != '.' else 'Root',
|
'{{folder}}': note.parent.name if str(note.parent) != '.' else 'Root',
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -412,6 +412,9 @@ Creates a new note from a template with placeholder replacement.
|
||||||
- `{{time}}` - Current time (HH:MM:SS)
|
- `{{time}}` - Current time (HH:MM:SS)
|
||||||
- `{{datetime}}` - Current datetime
|
- `{{datetime}}` - Current datetime
|
||||||
- `{{timestamp}}` - Unix timestamp
|
- `{{timestamp}}` - Unix timestamp
|
||||||
|
- `{{year}}` - Current year (YYYY)
|
||||||
|
- `{{month}}` - Current month (MM)
|
||||||
|
- `{{day}}` - Current day (DD)
|
||||||
- `{{title}}` - Note name without extension
|
- `{{title}}` - Note name without extension
|
||||||
- `{{folder}}` - Parent folder name
|
- `{{folder}}` - Parent folder name
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,9 @@ Create notes from reusable templates with dynamic placeholder replacement.
|
||||||
- `{{time}}` - Current time (HH:MM:SS)
|
- `{{time}}` - Current time (HH:MM:SS)
|
||||||
- `{{datetime}}` - Current date and time
|
- `{{datetime}}` - Current date and time
|
||||||
- `{{timestamp}}` - Unix timestamp
|
- `{{timestamp}}` - Unix timestamp
|
||||||
|
- `{{year}}` - Current year (YYYY)
|
||||||
|
- `{{month}}` - Current month (MM)
|
||||||
|
- `{{day}}` - Current day (DD)
|
||||||
- `{{title}}` - Note name (without extension)
|
- `{{title}}` - Note name (without extension)
|
||||||
- `{{folder}}` - Parent folder name
|
- `{{folder}}` - Parent folder name
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,9 @@ Templates support dynamic placeholders that are replaced when you create a note:
|
||||||
| `{{time}}` | Current time | `14:30:45` |
|
| `{{time}}` | Current time | `14:30:45` |
|
||||||
| `{{datetime}}` | Current date and time | `2025-11-26 14:30:45` |
|
| `{{datetime}}` | Current date and time | `2025-11-26 14:30:45` |
|
||||||
| `{{timestamp}}` | Unix timestamp | `1732632645` |
|
| `{{timestamp}}` | Unix timestamp | `1732632645` |
|
||||||
|
| `{{year}}` | Current year | `2025` |
|
||||||
|
| `{{month}}` | Current month | `11` |
|
||||||
|
| `{{day}}` | Current day | `26` |
|
||||||
| `{{title}}` | Note name (without .md) | `Weekly Meeting` |
|
| `{{title}}` | Note name (without .md) | `Weekly Meeting` |
|
||||||
| `{{folder}}` | Parent folder name | `Projects` |
|
| `{{folder}}` | Parent folder name | `Projects` |
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2547,6 +2547,9 @@
|
||||||
<code style="font-family: monospace;">{{date}}</code>,
|
<code style="font-family: monospace;">{{date}}</code>,
|
||||||
<code style="font-family: monospace;">{{time}}</code>,
|
<code style="font-family: monospace;">{{time}}</code>,
|
||||||
<code style="font-family: monospace;">{{datetime}}</code>,
|
<code style="font-family: monospace;">{{datetime}}</code>,
|
||||||
|
<code style="font-family: monospace;">{{year}}</code>,
|
||||||
|
<code style="font-family: monospace;">{{month}}</code>,
|
||||||
|
<code style="font-family: monospace;">{{day}}</code>,
|
||||||
<code style="font-family: monospace;">{{title}}</code>,
|
<code style="font-family: monospace;">{{title}}</code>,
|
||||||
<code style="font-family: monospace;">{{folder}}</code>
|
<code style="font-family: monospace;">{{folder}}</code>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue