Class: Howl::Post
Instance Attribute Summary
Attributes inherited from Template
#content, #extension, #path, #relative_path, #site, #view, #view_yaml
Instance Method Summary
collapse
Methods inherited from Template
#==, can_view, #converter, #initialize, #output_filename, #render, viewables
Constructor Details
This class inherits a constructor from Howl::Template
Instance Method Details
#<=>(other) ⇒ Object
9
10
11
|
# File 'lib/howl/post.rb', line 9
def <=>(other)
other.date <=> self.date
end
|
#date ⇒ Object
5
6
7
|
# File 'lib/howl/post.rb', line 5
def date
view.date? ? Time.parse(view.date.to_s) : File.mtime(path)
end
|
#dom_id ⇒ Object
21
22
23
|
# File 'lib/howl/post.rb', line 21
def dom_id
title.slugify
end
|
#link ⇒ Object
25
26
27
|
# File 'lib/howl/post.rb', line 25
def link
"/" + output_path.relative_path_from(site.output_path).to_s
end
|
#output_path ⇒ Object
13
14
15
|
# File 'lib/howl/post.rb', line 13
def output_path
site.output_path("posts") + date.strftime("%Y/%m/%d") + output_filename
end
|
#rendered_content ⇒ Object
29
30
31
32
33
|
# File 'lib/howl/post.rb', line 29
def rendered_content
render_view = view.dup
render_view.delete('template')
converter.convert(Mustache.render(@content, render_view))
end
|
#title ⇒ Object
17
18
19
|
# File 'lib/howl/post.rb', line 17
def title
view.title || path.basename(extension).to_s
end
|
#view_data ⇒ Object
35
36
37
38
39
|
# File 'lib/howl/post.rb', line 35
def view_data
{ :site => site,
:date => date,
:link => link }
end
|