Discover Packages
github.com/yixy/fmatter
package
module
Version:
v1.0.0
Opens a new window with list of versions in this module.
Published: Sep 24, 2019
License: MIT
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 1
Opens a new window with list of known importers.
README
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
Expand ▾
Collapse ▴
Documentation
¶
Package fmatter is a simple YAML Front Matter parser, using the
gopkg.in/yaml.v2 package.
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.
data := []byte(`---
title: Some Title
---
content`)
var frontmatter struct{ Title string }
content, _ := Read(data, &frontmatter)
fmt.Println(content)
Output:
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.
Source Files
¶
Directories
¶
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.
Click to show internal directories.
Click to hide internal directories.