3._write your query_: replace `[QUERY GOES HERE]` with any query you want using the options below.
4._available query options_: Usage of options is similar to SQL except for thespecial `render` option. The `render` option is used to display the data in a format that you created in a separate template.
*`where`
*`order by`
*`limit`
*`select`
*`render`
P.S.: If you are a developer or have a technical knowledge to read a code and would like to know more about syntax, please check out
Certain plugs can also provide special data sources to query specific data. Some examples are:
- [[🔌 Github]] provides `gh-pull` to query PRs for selected repo
- [[🔌 Mattermost]] provides `mm-saved` to fetch (by default 15) saved posts in
Mattermost
For a complete list of data sources, please check plugs’ own pages.
### 5. Templates
Templates are predefined formats to render the body of the query.
#### 5.1 How to create a template?
It is pretty easy. You just need to create a new page. However, it is
recommended to create your templates using `template/[TEMPLATE_NAME]`
convention. For this guide, we will create `template/plug` to display list of Plugs available in Silver Bullet. We will use this template in the Examples section below.
#### 5.2 What is the syntax?
We are using Handlebars which is a simple templating language. It is using double curly braces and the name of the parameter to be injected. For our `template/plug`, we are using simple template like below.
* [[{{name}}]] by **{{author}}** ([repo]({{repo}}))
Let me break it down for you
-`*` is creating a bullet point for each item in Silver Bullet
-`[[{{name}}]]` is injecting the name of Plug and creating an internal link to
the page of the Plug
-`**{{author}}**` is injecting the author of the Plug and making it bold
-`([repo]({{repo}}))` is injecting the name of the Plug and creating an
external link to the GitHub page of the Plug
For more information on the Handlebars syntax, you can read the
#### 6.4 Display the data in a format defined by a template
**Goal:** We would like to display the data from step 5.3 in a nice format using bullet points with links to Plug pages, with the author name and a link to their GitHub repo.
**Result:** Here you go. This is the result we would like to achieve 🎉. Did you see how I used `render` and `template/plug` in a query? 🚀
<!-- #query page select name author repo uririrririrririrririrririri where type = "plug" order by lastModified desc limit 5 render [[template/plug]] -->
* [[🔌 KaTeX]] by **Zef Hemel** ([repo](https://github.com/silverbulletmd/silverbullet-katex))
* [[🔌 Mermaid]] by **Zef Hemel** ([repo](https://github.com/silverbulletmd/silverbullet-mermaid))
* [[🔌 Mattermost]] by **Zef Hemel** ([repo](https://github.com/silverbulletmd/silverbullet-mattermost))