From dc33f6b3fade71b26bbc3c7b1cb56f2d3abb45a1 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Thu, 15 May 2014 23:55:39 -0700 Subject: [PATCH] Fix before_render after change to hooks-0.4.0. Related to #1278. --- .../lib/middleman-core/core_extensions/rendering.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index 98c0b600..2b5347a9 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -251,7 +251,12 @@ module Middleman template_class = Tilt[path] # Allow hooks to manipulate the template before render self.class.callbacks_for_hook(:before_render).each do |callback| - newbody = callback.call(body, path, locs, template_class) + # Uber::Options::Value doesn't respond to call + newbody = if callback.respond_to?(:call) + callback.call(body, path, locs, template_class) + elsif callback.respond_to?(:evaluate) + callback.evaluate(self, body, path, locs, template_class) + end body = newbody if newbody # Allow the callback to return nil to skip it end @@ -266,11 +271,12 @@ module Middleman # Allow hooks to manipulate the result after render self.class.callbacks_for_hook(:after_render).each do |callback| # Uber::Options::Value doesn't respond to call - if callback.respond_to?(:call) + newcontent = if callback.respond_to?(:call) content = callback.call(content, path, locs, template_class) elsif callback.respond_to?(:evaluate) content = callback.evaluate(self, content, path, locs, template_class) end + content = newcontent if newcontent # Allow the callback to return nil to skip it end output = ::ActiveSupport::SafeBuffer.new ''