mirror of
https://github.com/lloeki/tilt-pdf-rails.git
synced 2025-12-06 10:34:42 +01:00
25 lines
532 B
Ruby
25 lines
532 B
Ruby
require 'tilt-pdf'
|
|
require 'action_view/template/handlers'
|
|
|
|
module ActionView
|
|
class Template
|
|
module Handlers
|
|
class PDFTemplate
|
|
class_attribute :default_format
|
|
self.default_format = :pdf
|
|
|
|
def call(template)
|
|
"Tilt.new('#{template.identifier}').render(self)"
|
|
end
|
|
end
|
|
end
|
|
|
|
register_template_handler :rpdf, Handlers::PDFTemplate.new
|
|
end
|
|
end
|
|
|
|
module Tilt::PDFTemplate::Rails
|
|
class Railtie < ::Rails::Railtie
|
|
config.app_generators.template_engine :rpdf
|
|
end
|
|
end
|