module Roda::RodaPlugins::CaptureERB::InstanceMethods

  1. lib/roda/plugins/capture_erb.rb


Public Instance

  1. capture_erb

Public Instance methods


Temporarily replace the ERB output buffer with an empty string, and then yield to the block. Return the value of the block, converted to a string. Restore the previous ERB output buffer before returning.

[show source]
   # File lib/roda/plugins/capture_erb.rb
28 def capture_erb
29   outvar = render_opts[:template_opts][:outvar]
30   buf_was = instance_variable_get(outvar)
31   instance_variable_set(outvar,
32   yield.to_s
33 ensure
34   instance_variable_set(outvar, buf_was) if outvar && buf_was
35 end