Guides

Template Variables

Nizel supports variable injection before Markdown parsing. Use {{ expression }} syntax in both frontmatter and body content.

Basic Usage

const { html } = await nizel(
  '# Hello {{ name }}',
  { variables: { name: 'World' } },
);
// <h1>Hello World</h1>

In Frontmatter

const { meta } = await nizel(`
---
title: 
slug: 
---
Content here.
`, { variables: { product: { name: 'nizel handbook' } } });
// meta.title === 'Nizel Handbook'
// meta.slug === 'nizel-handbook'

In Body

const { html } = await nizel(
  `Price: €0.00`,
  { variables: { price: 29.99 } },
);

From Frontmatter

Values declared in frontmatter are available as body template variables:

---
entityName: Henk
documentName: "{{ entityName }} service agreement"
---

# 

This agreement is between {{ entityName }} and the customer.

Use {{ frontmatter.entityName }} or {{ meta.entityName }} when you want to be explicit about where the value came from. Runtime variables and data override same-name frontmatter values.

Nested Access

Dot notation works for nested objects:

{{ user.name }}
{{ config.theme.primary }}
{{ items.length }}

Filters

Variables can be piped through filters:



$0.00
NaN January,February,March,April,May,June,July,August,September,October,November,December NaN

See Filters for the full list.