class Inert::Page
Attributes
body[R]
filename[R]
frontmatter[R]
layout[R]
Public Class Methods
find_file(filename)
click to toggle source
# File lib/inert/page.rb, line 34 def self.find_file(filename) Dir[filename + ".*"].first end
load_from_file(filename)
click to toggle source
# File lib/inert/page.rb, line 18 def self.load_from_file(filename) filename = find_file(filename) raise Errno::ENOENT if filename.nil? body = File.read(filename) frontmatter = {} body = body.gsub(/---(.*)---/m) do |m| frontmatter = YAML.load($1) "" end.lstrip new(body: body, frontmatter: frontmatter, filename: filename) end
new(body: "", frontmatter: {}, filename: nil)
click to toggle source
# File lib/inert/page.rb, line 9 def initialize(body: "", frontmatter: {}, filename: nil) @body = body @frontmatter = frontmatter @layout = @frontmatter.delete("layout") || "layout" @filename = filename @frontmatter = OpenStruct.new(@frontmatter) end