Class: Retter::Page::Article

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/retter/page/article.rb

Defined Under Namespace

Classes: ViewContext

Instance Attribute Summary collapse

Attributes included from Base

#path_prefix, #title

Instance Method Summary collapse

Methods included from Site

#config, #entries, #load, #reset!

Methods included from Configurable

#configurable, #define_configurable_method, #define_instance_shortcut_method

Constructor Details

#initialize(article) ⇒ Article

Returns a new instance of Article.



18
19
20
21
22
23
# File 'lib/retter/page/article.rb', line 18

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

Instance Attribute Details

#articleObject (readonly)

Returns the value of attribute article.



16
17
18
# File 'lib/retter/page/article.rb', line 16

def article
  @article
end

Instance Method Details

#bindObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/retter/page/article.rb', line 33

def bind
  context = ViewContext.new(article.entry, article)
  part    = Tilt.new(
    template_path.to_path,
    ugly: true,
    filename: template_path.to_path
  ).render(context)

  print part
end

#pathObject



25
26
27
# File 'lib/retter/page/article.rb', line 25

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

#template_pathObject



29
30
31
# File 'lib/retter/page/article.rb', line 29

def template_path
  Page.find_template_path('article')
end