From 03547ca9d0e003490965658c4a1d58f87c3a4d8e Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" Date: Sun, 21 Aug 2022 20:49:49 +0000 Subject: [PATCH] How to use the template? --- website/🔌 Query.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/website/🔌 Query.md b/website/🔌 Query.md index d63bab3..bec5982 100644 --- a/website/🔌 Query.md +++ b/website/🔌 Query.md @@ -94,14 +94,14 @@ For a complete list of data sources, please check plugs’ pages. 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 example section below. +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 name of parameter to be injected. For our `template/plug`, we are using simple template like below. `* [[{{name}}]] by **{{author}}** ([repo]({{repo}}))` -Let me explain the each part +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 @@ -109,6 +109,13 @@ Let me explain the each part For more information on the Handlebars syntax, you can read the [official documentation](https://handlebarsjs.com/). +#### 5.3 How to use the template? +You just need to add `render` keyword followed by the link of the template to the query like below: + +`#query page where type = "plug" render [[template/plug]]` + +You can see the usage of our template in the example 6.4 below. + ### 6. Examples We will walk you through a set of examples starting from very basic one until to format the data using templates.