Sha256: cac3b9ca4dd8fcb3517e23d862017606dfc370bcee336e96e009c99ecda2e1a6

Contents?: true

Size: 735 Bytes

Versions: 1

Compression:

Stored size: 735 Bytes

Contents

# coding: utf-8

class Retter::Pages::Article
  include Retter::Page

  attr_reader :article

  def initialize(article)
    super()
    @path_prefix = '../../'
    @article     = article
    @title       = "#{article.title} - #{config.title}"
  end

  def pathname
    config.entry_dir(article.entry.date).join("#{article.id}.html")
  end

  def part_layout_pathname
    config.article_layout_file
  end

  def print
    options = {entry: article.entry, article: article}
    part = Haml::Engine.new(part_layout_pathname.read, ugly: true).render(view_scope, options)

    mkdir
    print_with_layout part
  end

  def mkdir
    entry_dir = config.entry_dir(article.entry.date)
    entry_dir.mkdir unless entry_dir.directory?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
retter-0.1.1 lib/retter/pages/article.rb