Module: YAML::FrontMatter

Defined in:
lib/yaml/front-matter.rb

Constant Summary collapse

PATTERN =
/\A(---\r?\n(.*?)\n?^---\s*$\n?)/m

Class Method Summary collapse

Class Method Details

.extract(content) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/yaml/front-matter.rb', line 8

def extract(content)
  if content =~ PATTERN
    return [YAML.load($2), content.sub($1, "")]
  else
    return [{}, content]
  end
end