fmatter

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2019 License: MIT Imports: 6 Imported by: 1

README

fmatter

A simple YAML Front Matter parser, using the gopkg.in/yaml.v2 package. View the godoc documentation here.

forked from james4k/fmatter:

  • add go mod and tag v1.0.0

Documentation

Overview

Package fmatter is a simple YAML Front Matter parser, using the gopkg.in/yaml.v2 package.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(data []byte, frontmatter interface{}) (content []byte, err error)

Read detects and parses the front matter data, and returns the remaining contents. If no front matter is found, the entire file contents are returned. For details on the frontmatter parameter, please see the gopkg.in/yaml.v2 package.

Example
data := []byte(`---
title: Some Title
---
content`)

var frontmatter struct{ Title string }
content, _ := Read(data, &frontmatter)
fmt.Println(content)
Output:

func ReadFile

func ReadFile(filename string, frontmatter interface{}) (content []byte, err error)

ReadFile read an entire file into memory, and calls Read which parses the front matter data and returns the remaining file contents.

Types

This section is empty.

Directories

Path Synopsis
Package fmatter is a TOML Front Matter parser, using the github.com/BurntSushi/toml package.
Package fmatter is a TOML Front Matter parser, using the github.com/BurntSushi/toml package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL