2022-10-28 14:17:40 +00:00
---
type: plug
repo: https://github.com/silverbulletmd/silverbullet
---
2023-10-03 12:16:33 +00:00
> **Warning** Deprecated
> Directives are now deprecated and will likely soon be removed, use [[Live Templates]] and [[Live Queries]] instead.
2022-10-28 14:17:40 +00:00
The directive plug is a built-in plug implementing various so-called “directive” that all take the form of `<!-- #directiveName ... -->` and close with `<!-- /directiveName -->` . Currently the following directives are supported:
2023-10-03 12:16:33 +00:00
* `#query` to perform queries: [[Live Queries]]
2022-10-28 14:17:40 +00:00
* `#include` to inline the content of another page verbatim: [[@include]]
* `#use` to use the content of another as a [handlebars ](https://handlebarsjs.com/ ) template: [[@use]]
* `#eval` to evaluate an arbitrary JavaScript expression and inline the result: [[@eval]]
## Include
$include
The `#include` directive can be used to embed another page into your existing one. The syntax is as follows:
<!-- #include [[page reference]] -->
<!-- /include -->
Whenever the directives are updated, the body of the directive will be replaced with the latest version of the reference page.
## Use
$use
2023-07-07 18:21:50 +00:00
The `#use` directive can be used to use a referenced page as a handlebars template. Optionally, a JSON object can be passed as argument to the template:
2022-10-28 14:17:40 +00:00
2022-11-01 16:03:42 +00:00
<!-- #use [[template/plug]] {"name": "🔌 Directive", "repo": "https://google.com", "author": "Pete"} -->
2022-10-28 14:17:40 +00:00
<!-- /use -->
which renders as follows:
2022-11-01 16:03:42 +00:00
<!-- #use [[template/plug]] {"name": "🔌 Directive", "repo": "https://google.com", "author": "Pete"} -->
* [[🔌 Directive]] by **Pete** ([repo](https://google.com))
2022-10-28 14:17:40 +00:00
<!-- /use -->
2022-12-14 19:04:20 +00:00
* [ ] #test This is a test task
2022-10-28 14:17:40 +00:00
Note that a string is also a valid JSON value:
2023-07-07 18:21:50 +00:00
So, for instance, a template can take a tag name as an argument:
2022-10-28 14:17:40 +00:00
2022-11-25 15:01:05 +00:00
<!-- #use [[template/tagged-tasks]] "test" -->
* [ ] [[🔌 Directive@1537]] This is a test task #test
<!-- /use -->