Merge pull request #761 from LeonB/3.0-stable

Added before_render & after_render hook
This commit is contained in:
Thomas Reynolds 2013-02-02 14:08:10 -08:00
commit 8996e65fd1

View file

@ -19,6 +19,9 @@ module Middleman
# Include methods # Include methods
app.send :include, InstanceMethods app.send :include, InstanceMethods
app.define_hook :before_render
app.define_hook :after_render
# Activate custom renderers # Activate custom renderers
require "middleman-core/renderers/erb" require "middleman-core/renderers/erb"
app.register Middleman::Renderers::ERb app.register Middleman::Renderers::ERb
@ -249,7 +252,10 @@ module Middleman
end end
# Render using Tilt # Render using Tilt
template.render(context, locs, &block) run_hook :before_render, template.data, template
content = template.render(context, locs, &block)
run_hook :after_render, content, template
return content
ensure ensure
# Reset stored buffer # Reset stored buffer
@_out_buf = _buf_was @_out_buf = _buf_was