Class: Jekyll::Document
- Inherits:
-
Object
- Object
- Jekyll::Document
- Defined in:
- lib/octopress-hooks.rb
Overview
Monkey patch Jekyll’s Document class
Instance Method Summary collapse
- #hooks ⇒ Object
-
#initialize(*args) ⇒ Document
constructor
A new instance of Document.
- #merge_payload(payload) ⇒ Object
- #old_initialize ⇒ Object
- #old_write ⇒ Object
- #post_init ⇒ Object
- #post_render ⇒ Object
- #post_write ⇒ Object
- #pre_render ⇒ Object
- #write(dest) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Document
Returns a new instance of Document.
221 222 223 224 |
# File 'lib/octopress-hooks.rb', line 221 def initialize(*args) old_initialize(*args) post_init if place_in_layout? end |
Instance Method Details
#hooks ⇒ Object
232 233 234 |
# File 'lib/octopress-hooks.rb', line 232 def hooks @hooks ||= site.all_hooks + site.doc_hooks end |
#merge_payload(payload) ⇒ Object
248 249 250 251 252 253 254 255 256 |
# File 'lib/octopress-hooks.rb', line 248 def merge_payload(payload) hooks.each do |hook| p = hook.merge_payload(payload, self) if p && p.is_a?(Hash) payload = Jekyll::Utils.deep_merge_hashes(payload, p) end end payload end |
#old_initialize ⇒ Object
218 |
# File 'lib/octopress-hooks.rb', line 218 alias_method :old_initialize, :initialize |
#old_write ⇒ Object
219 |
# File 'lib/octopress-hooks.rb', line 219 alias_method :old_write, :write |
#post_init ⇒ Object
236 237 238 239 240 |
# File 'lib/octopress-hooks.rb', line 236 def post_init hooks.each do |hook| hook.post_init(self) end end |
#post_render ⇒ Object
258 259 260 261 262 |
# File 'lib/octopress-hooks.rb', line 258 def post_render hooks.each do |hook| hook.post_render(self) end end |
#post_write ⇒ Object
264 265 266 267 268 |
# File 'lib/octopress-hooks.rb', line 264 def post_write hooks.each do |hook| hook.post_write(self) end end |
#pre_render ⇒ Object
242 243 244 245 246 |
# File 'lib/octopress-hooks.rb', line 242 def pre_render hooks.each do |hook| hook.pre_render(self) end end |
#write(dest) ⇒ Object
226 227 228 229 230 |
# File 'lib/octopress-hooks.rb', line 226 def write(dest) post_render if place_in_layout? old_write(dest) post_write if place_in_layout? end |