class ContentDirectory::Entry

Attributes

metadata[R]
path[R]
text[R]

Public Class Methods

new(path) click to toggle source
# File lib/content_directory/entry.rb, line 8
def initialize(path)
  @path = path
  @text = File.read "#{ContentDirectory.root}/#{@path}"
  @metadata, @text = @text.split("\n\n", 2)

  begin
    @metadata = YAML.load @metadata
  rescue Exception => e
    @metadata = nil
  end
end

Public Instance Methods

html() click to toggle source
# File lib/content_directory/entry.rb, line 20
def html
  return nil unless @text
  markdown = Redcarpet::Markdown.new Redcarpet::Render::HTML
  html = markdown.render @text
  Redcarpet::Render::SmartyPants.render html
end