Module: Jekyll::Convertible
- Defined in:
- lib/octopress-hooks.rb
Overview
Monkey patch for the Jekyll Convertible module.
Instance Method Summary collapse
-
#do_layout(payload, layouts) ⇒ Object
Calls the pre_render method if it exists and then adds any necessary layouts to this convertible document.
-
#full_url ⇒ Object
Returns the full url of the post, including the configured url.
- #hooks ⇒ Object
- #merge_payload(payload) ⇒ Object
- #old_do_layout ⇒ Object
- #old_write ⇒ Object
- #post_init ⇒ Object
- #post_render ⇒ Object
- #post_write ⇒ Object
- #pre_render ⇒ Object
-
#write(dest) ⇒ Object
Write the generated post file to the destination directory.
Instance Method Details
#do_layout(payload, layouts) ⇒ Object
Calls the pre_render method if it exists and then adds any necessary layouts to this convertible document.
payload - The site payload Hash. layouts - A Hash of => “layout”.
Returns nothing.
314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/octopress-hooks.rb', line 314 def do_layout(payload, layouts) pre_render if respond_to?(:pre_render) && hooks if respond_to?(:merge_payload) && hooks old_do_layout(merge_payload(payload.dup), layouts) else old_do_layout(payload, layouts) end post_render if respond_to?(:post_render) && hooks end |
#full_url ⇒ Object
Returns the full url of the post, including the configured url
376 377 378 |
# File 'lib/octopress-hooks.rb', line 376 def full_url File.join(site.config['url'], url) end |
#hooks ⇒ Object
336 337 338 |
# File 'lib/octopress-hooks.rb', line 336 def hooks [] end |
#merge_payload(payload) ⇒ Object
346 347 348 349 350 351 352 353 354 |
# File 'lib/octopress-hooks.rb', line 346 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_do_layout ⇒ Object
304 |
# File 'lib/octopress-hooks.rb', line 304 alias_method :old_do_layout, :do_layout |
#old_write ⇒ Object
305 |
# File 'lib/octopress-hooks.rb', line 305 alias_method :old_write, :write |
#post_init ⇒ Object
340 341 342 343 344 |
# File 'lib/octopress-hooks.rb', line 340 def post_init hooks.each do |hook| hook.post_init(self) end end |
#post_render ⇒ Object
362 363 364 365 366 |
# File 'lib/octopress-hooks.rb', line 362 def post_render hooks.each do |hook| hook.post_render(self) end end |
#post_write ⇒ Object
368 369 370 371 372 |
# File 'lib/octopress-hooks.rb', line 368 def post_write hooks.each do |hook| hook.post_write(self) end end |
#pre_render ⇒ Object
356 357 358 359 360 |
# File 'lib/octopress-hooks.rb', line 356 def pre_render hooks.each do |hook| hook.pre_render(self) end end |
#write(dest) ⇒ Object
Write the generated post file to the destination directory. It then calls any post_write methods that may exist.
+dest+ is the String path to the destination dir
Returns nothing
331 332 333 334 |
# File 'lib/octopress-hooks.rb', line 331 def write(dest) old_write(dest) post_write if respond_to?(:post_write) && hooks end |