Class: Octopress::Partial

Inherits:
Object
  • Object
show all
Includes:
Jekyll::Convertible
Defined in:
lib/octopress-render-tag/hooks.rb

Overview

Create a new page class to allow partials to trigger Octopress Hooks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, name, content) ⇒ Partial

Returns a new instance of Partial.



12
13
14
15
16
17
18
19
# File 'lib/octopress-render-tag/hooks.rb', line 12

def initialize(site, name, content)
  @site     = site
  @name     = name
  @ext      = File.extname(name)
  @content  = content
  @data     = { layout: nil } # hack
  
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



10
11
12
# File 'lib/octopress-render-tag/hooks.rb', line 10

def content
  @content
end

#dataObject

Returns the value of attribute data.



10
11
12
# File 'lib/octopress-render-tag/hooks.rb', line 10

def data
  @data
end

#extObject

Returns the value of attribute ext.



10
11
12
# File 'lib/octopress-render-tag/hooks.rb', line 10

def ext
  @ext
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/octopress-render-tag/hooks.rb', line 10

def name
  @name
end

#outputObject

Returns the value of attribute output.



10
11
12
# File 'lib/octopress-render-tag/hooks.rb', line 10

def output
  @output
end

#siteObject

Returns the value of attribute site.



10
11
12
# File 'lib/octopress-render-tag/hooks.rb', line 10

def site
  @site
end

Instance Method Details

#hooksObject



27
28
29
30
31
32
33
# File 'lib/octopress-render-tag/hooks.rb', line 27

def hooks
  if self.site.respond_to? :page_hooks
    self.site.page_hooks
  else
    []
  end
end

#post_renderObject



41
42
43
44
45
# File 'lib/octopress-render-tag/hooks.rb', line 41

def post_render
  self.hooks.each do |hook|
    hook.post_render(self)
  end
end

#pre_renderObject



35
36
37
38
39
# File 'lib/octopress-render-tag/hooks.rb', line 35

def pre_render
  self.hooks.each do |hook|
    hook.pre_render(self)
  end
end

#render(payload) ⇒ Object



21
22
23
24
25
# File 'lib/octopress-render-tag/hooks.rb', line 21

def render(payload)
  pre_render
  do_layout(payload, { no_layout: nil })
  post_render
end