module FrontMatter

Defined in:

front_matter.cr

Class Method Summary

Class Method Detail

def self.open(filename : String, skip_newlines : Bool = true, strip : Bool = true, &block : String, IO::FileDescriptor -> Nil) : Nil #

Opens the file named by filename. Yields the frontmatter as a String and the file descriptor positioned at the start of the content to the given block. If the contents leading newlines are desired setting skip_newlines to false will prevent it from being skipped. By defualt the resultant front matter string will be stripped. To prevent this add the arguement strip: false.


[View source]
def self.parse(io : IO, skip_newlines : Bool = true, strip : Bool = true, &block : String, IO -> Nil) : Nil #

Parses the IO given as io. Yields the frontmatter as a String and the IO positioned at the start of the content to the given block. If the contents leading newlines are desired setting skip_newlines to false will prevent it from being skipped. By defualt the resultant front matter string will be chomp'ed. To prevent this add the arguement chomp: false.

Note: The provided IO must support #.seek.


[View source]
def self.parse(string : String, skip_newlines : Bool = true, strip : Bool = true, &block : String, String -> Nil) : Nil #

Parses the String given as string. Yields the frontmatter as a String and the remaineder as a String to the given block. If the contents leading newlines are desired setting skip_newlines to false will prevent it from being skipped. By defualt the resultant front matter string will be stripped. To prevent this add the arguement strip: false.

Note: This should not be used in most cases. It converts between String and IO::Memory numerous times and is only included to make testing easier.


[View source]