hyogen-md

0.10.0

Includes and Components

Reuse content across files with include, parameterized component, and layout inheritance with extend + block.

include

Inlines another .md file at the current position. No props. Parent scope variables are visible.

<!--
@hg
include ./partials/description.md
@endhg
-->

Use include when you only need to splice content — no parameters.

component

Register a component file under an alias, then call it in &#123;&#123; &#125;&#125; expressions.

Component file (city-item.md):

---
props:
  city:
    type: string
  population:
    type: number
---

Name: {{ city }} / Population: {{ population.toLocaleString('en-US') }}

Parent file:

<!--
@hg
component city-item.md as cityItem
@endhg
-->

- {{ cityItem({ city: "Osaka", population: 2825000 }) }}
- {{ cityItem({ city: "Kobe", population: 1490000 }) }}

Rules

RuleDetail
Registrationcomponent <path> as <name> in @hg
Call site&#123;&#123; name({ ... }) &#125;&#125; only
OutputMust be single line — multiline output errors
Alias scopeVisible in the defining file and included children
Alias collisionError — choose unique names
extend inside componentSkipped with extend_in_component warning

In each loops

<!--
@hg
component city-item.md as cityItem
const cities = [
  { name: "Osaka", population: 2825000 },
  { name: "Kobe", population: 1490000 },
]
@endhg
-->

<!--
@hg
each item in cities
@endhg
-->
- {{ cityItem({ city: item.name, population: item.population }) }}
<!--
@hg
endeach
@endhg
-->

extend and block

Layout inheritance (Pug / Blade style). Only single inheritance — no layout chains.

Layout (layout.md):

# {{ title }}

<!--
@hg
block contents
@endhg
-->

Default body text.

<!--
@hg
endblock
@endhg
-->

Page (page.md):

<!--
@hg
extend layout.md
const title = "My Page"
@endhg
-->

<!--
@hg
block contents
@endhg
-->

Overridden body.

<!--
@hg
endblock
@endhg
-->
RuleDetail
extend positionFirst @hg block (front matter may precede it)
Child body outside blocksIgnored
Unoverridden blocksLayout default kept
Close tagendblock only

Circular references

Circular include / component / extend chains are detected, skipped, and reported as circular_include warnings.