1
0
silverbullet/website/Slash Templates.md

44 lines
1.2 KiB
Markdown
Raw Normal View History

2023-12-21 17:37:50 +00:00
Slash templates allow you to define custom [[Slash Commands]] that expand “snippet style” templates inline.
2023-11-11 13:28:46 +00:00
2023-12-21 17:37:50 +00:00
# Definition
You can define a slash template by creating a [[Templates|template page]] with a template tag and `trigger` attribute. If youd like to (temporarily) disable the template, you can set the `enabled` attribute to `false`.
2023-11-11 13:28:46 +00:00
Example:
---
tags: template
trigger: meeting-notes
---
## Meeting notes for {{today}}!
|^|
## Frontmatter
2023-12-21 17:37:50 +00:00
A templates [[Frontmatter]] is interpreted by SilverBullets [[Templates|template]] engine and removed when instantiated. However, to still include frontmatter after instantiation, you can use the `frontmatter` attribute.
2023-11-11 13:28:46 +00:00
Example:
---
tags: template
trigger: meeting-notes
frontmatter: |
date: {{today}}
---
## Meeting notes for {{today}}!
|^|
Which will expand into e.g.
---
date: 2023-11-11
---
## Meeting notes for 2023-11-11
.
2023-12-21 17:37:50 +00:00
When the page already contains frontmatter before invoking the slash command, it will be augmented with the additional frontmatter specified by the template.
# Use
You can _trigger_ the slash template by typing `/<trigger>` (e.g. `/meeting-notes`) in any page.