Class: Retter::Page::Entry

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/retter/page/entry.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(entry) ⇒ Entry

Returns a new instance of Entry.



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

def initialize(entry)
  super()

  @path_prefix = '../'
  @entry       = entry
  @title       = "#{entry.date} - #{config.title}"
end

Instance Attribute Details

#entryObject (readonly)

Returns the value of attribute entry.



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

def entry
  @entry
end

Instance Method Details

#bindObject



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

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

  print part
end

#pathObject



26
27
28
# File 'lib/retter/page/entry.rb', line 26

def path
  Page.entry_file(entry.date)
end

#template_pathObject



30
31
32
# File 'lib/retter/page/entry.rb', line 30

def template_path
  Page.find_template_path('entry')
end