Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Queries

Bruno Meilick edited this page Mar 8, 2020 · 3 revisions

build-in queries

The plugin has a few queries built-in. This allows you to use the queried result directly in your handlebar templates. For example you can use {{ page.title }} in any handlebars template without having to define that value yourself. You can override these in the bnomei.handlebars.queries option.

{{ site.title }}
{{ site.url }}
{{ page.autoid }}
{{ page.title }}
{{ page.text }}
{{ page.url }}
{{ page.slug }}
{{ page.template }}

automatic parsing of queries in all fields

You can also use queries when providing data from controllers or models. Further more any plain string will be parsed as a query. This allows you to write queries in textarea fields as well.

/content/blog/unesco-heritage/post.txt

Title: Unesco heritage
----
Date: 2017-12-07
----
Art: twirling
----
Text:
On {{ page.date.toDate('d.m.Y') }} the Neapolitan art of pizza {{ page.art }} 
has joined Unesco’s list of intangible heritage.

/site/templates/post.hbs

<article id="{{ page.slug }}">
  <h2>{{ page.title }}</h2>
  {{ page.text }}
</article>

localhost:80/blog/unesco-heritage

<article id="unesco-heritage">
  <h2>Unesco heritage</h2>
  <p>On 07.12.2020 the Neapolitan art of pizza twirling 
has joined Unesco’s list of intangible heritage.</p>
</article>

Settings

bnomei.handlebars. Default Description
queries [...] an array of predefined queries you can use in your templates