Adding an "enabled" attribute to templates

This commit is contained in:
Zef Hemel
2024-01-11 14:06:24 +01:00
parent 154d9a8ce9
commit 509ece91f0
9 changed files with 43 additions and 11 deletions
+1
View File
@@ -12,6 +12,7 @@ Live Template Widgets follow the same pattern as other [[Templates]] with a few
* `type`: should be set to `widget:top` or `widget:bottom` depending on where you would like it to appear
* `where`: should contain an [[Live Queries$expression]] that evaluates to true for the _pages_ you would like to apply this template to, usually this checks for a specific tag, but it can be any expression. Think of this as a `where` clause that should match for the pages this template is applied to.
* `priority` (optional): in case you have multiple templates that have matching `where` expression, the one with the priority set to the lowest number wins.
* `enabled` (defaults to `true`): in case you want to (temporarily) disable this template, set this to `false`.
# Example
The following widget template applies to all pages tagged with `person` (see the `where`). It uses the [[!silverbullet.md/template/live/incoming]] template, to show all incomplete tasks that reference this particular page.
+1 -1
View File
@@ -1,7 +1,7 @@
Slash templates allow you to define custom [[Slash Commands]] that expand “snippet style” templates inline.
# Definition
You can define a slash template by creating a [[Templates|template page]] with a template tag and `trigger` attribute.
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`.
Example:
+2 -2
View File
@@ -5,7 +5,7 @@ This is an attempt at collecting useful, reusable templates so you dont have
While you may just copy & paste these templates to your own space, the most convenient ways to use them is using [[Federation]]. This will synchronize these templates into your space and make them available for use instantly.
To set this up, add the following this to your [[SETTINGS]]:
To set this up, add the following to your [[SETTINGS]]:
```yaml
federate:
@@ -56,7 +56,7 @@ render [[template/documented-template]]
```
# Live Widget Templates
Use these to add [[Table of Contents]] and [[Linked Mentions]] to your pages.
Use these to add various useful [[Live Template Widgets]] to your pages.
```query
template
@@ -0,0 +1,10 @@
---
description: >
Adds a convenient "Copy to my space" button to any
template found via federation
tags: template
type: widget:bottom
where: 'name =~ /^!/ and tags="template"'
---
# Template actions
* {[Page: Copy|Copy to my space]}: use this template in your space by making a local copy of it (and tweaking it as you like)