xp-forge / handlebars-templates

Handlebars templates for XP web frontends
1 stars 0 forks source link

Support YAML front matter #7

Closed thekid closed 3 years ago

thekid commented 3 years ago

YFM is an optional section of valid YAML that is placed at the top of a page and is used for maintaining metadata for the page and its contents.

How it works:

---
nav:
- home
- profile
- settings
---
<!DOCTYPE html>
...
<nav>
  {{#each nav}}
     <a href="/{{.}}">{{lookup translations .}}</a>
  {{/each}}
</nav>

See also:

thekid commented 3 years ago

We could do without extra dependencies if we used JSON front matter, however, there seems to be no agreed-upon standard for doing this. Some use curly braces:

{
  "key": "value"
}
<!DOCTYPE html>
...

...other use ---json like seen in https://www.11ty.dev/docs/data-frontmatter/#json-front-matter or a curly-less version and three semicolons:

"key": "value"
;;;
<!DOCTYPE html>
...

...and yet other include three leading semicolons. All of them don't "feel" natural.

thekid commented 3 years ago

PR #8 merged and released in https://github.com/xp-forge/handlebars-templates/releases/tag/v0.9.0