Fix before_render after change to hooks-0.4.0. Related to #1278.

This commit is contained in:
Ben Hollis 2014-05-15 23:55:39 -07:00
parent f29994e25a
commit dc33f6b3fa

View file

@ -251,7 +251,12 @@ module Middleman
template_class = Tilt[path] template_class = Tilt[path]
# Allow hooks to manipulate the template before render # Allow hooks to manipulate the template before render
self.class.callbacks_for_hook(:before_render).each do |callback| 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 body = newbody if newbody # Allow the callback to return nil to skip it
end end
@ -266,11 +271,12 @@ module Middleman
# Allow hooks to manipulate the result after render # Allow hooks to manipulate the result after render
self.class.callbacks_for_hook(:after_render).each do |callback| self.class.callbacks_for_hook(:after_render).each do |callback|
# Uber::Options::Value doesn't respond to call # 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) content = callback.call(content, path, locs, template_class)
elsif callback.respond_to?(:evaluate) elsif callback.respond_to?(:evaluate)
content = callback.evaluate(self, content, path, locs, template_class) content = callback.evaluate(self, content, path, locs, template_class)
end end
content = newcontent if newcontent # Allow the callback to return nil to skip it
end end
output = ::ActiveSupport::SafeBuffer.new '' output = ::ActiveSupport::SafeBuffer.new ''