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: {{ product.name | title }}
slug: {{ product.name | kebab }}
---
Content here.
`, { variables: { product: { name: 'nizel handbook' } } });
// meta.title === 'Nizel Handbook'
// meta.slug === 'nizel-handbook'
In Body
const { html } = await nizel(
`Price: {{ price | format('currency', 'EUR') }}`,
{ variables: { price: 29.99 } },
);
Nested Access
Dot notation works for nested objects:
{{ user.name }}
{{ config.theme.primary }}
{{ items.length }}
Filters
Variables can be piped through filters:
{{ name | capitalize }}
{{ name | kebab }}
{{ price | format('currency', 'USD') }}
{{ date | format('date', 'dd MMM yyyy') }}
See Filters for the full list.