Module: Dimples::Frontable

Included in:
Page, Template
Defined in:
lib/dimples/frontable.rb

Instance Method Summary collapse

Instance Method Details

#read_with_front_matter(path) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dimples/frontable.rb', line 5

def read_with_front_matter(path)
  contents = File.read(path)

  if (matches = contents.match(/^(-{3}\n.*?\n?)^(-{3}*$\n?)/m))
     = Hashie.symbolize_keys(YAML.safe_load(matches[1]))
    contents = matches.post_match.strip
  else
     = {}
  end

  [contents, ]
end