Download the PHP package hkod/frontmatter without Composer
On this page you can find all versions of the php package hkod/frontmatter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hkod/frontmatter
More information about hkod/frontmatter
Files in hkod/frontmatter
Package frontmatter
Short Description A context aware frontmatter parser that supports multiple formats and uses a clean OOP architecture
License Unlicense
Homepage https://github.com/hanneskod/frontmatter
Informations about the package frontmatter
frontmatter
A context aware frontmatter parser that supports multiple formats and uses a clean OOP architecture.
Front matter is metadata located at the top of a file wrapped in delimiting
line tokens, usually ---
. The front matter may be formatted using YAML, Json
or any ohter simliar format such as NEON or TOML.
Supported formats:
- Json
- INI
- YAML (
require symfony/yaml
) - Markdown (
require erusev/parsedown
) - Mustache (
require mustache/mustache
)
Parsers are simple callables, super easy to add more formats.
Installation
Usage
A standard parser with yaml frontmatter and markdown body:
Specify the front matter delimiter
Note that the delimiting tokens always represents full lines.
You may set the delimiters when creating the block parser.
Putting the frontmatter last
Note that since the delimiting tokens represent a line the last line must end whit a new line (or similar) or it won't be recognized by the parser.
Frontmatter also supports an inverted block parser, where the frontmatter is expected to bee last instead of first.
Passing a context
When parsing you may pass a context to the parser and it will in turn be passed along to all subsequent parsers. Context dependet parsers may for example expand templates...