Skip to content

Instantly share code, notes, and snippets.

@markbates
Created August 16, 2008 19:29
Show Gist options
  • Save markbates/5741 to your computer and use it in GitHub Desktop.
Save markbates/5741 to your computer and use it in GitHub Desktop.
module Mack
module Rendering # :nodoc:
module Engine # :nodoc:
class Pdf < Mack::Rendering::Engine::Base
def render(io, binding)
if io.is_a?(File)
io = io.read
end
@_pdf = ::PDF::Writer.new
self.view_template.instance_variable_set("@_pdf", @_pdf)
eval(io, binding)
@_pdf.render
end
def extension
:pdfw
end
module ViewHelpers
def pdf
@_pdf
end
end
end
end
end
end
Mack::Rendering::ViewTemplate.send(:include, Mack::Rendering::Engine::Pdf::ViewHelpers)
Mack::Rendering::Engine::Registry.instance.register(:action, :pdf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment