Class: WickedPdf::Renderer
- Inherits:
-
Object
- Object
- WickedPdf::Renderer
- Defined in:
- lib/wicked_pdf/renderer.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(controller) ⇒ Renderer
constructor
A new instance of Renderer.
-
#prepare(options) ⇒ Object
Renders the template and any header/footer templates WITHOUT invoking wkhtmltopdf, returning { html:, options: } suitable for Document#pdfs_from_strings.
- #render(options) ⇒ Object
- #render_to_string(options) ⇒ Object
Constructor Details
#initialize(controller) ⇒ Renderer
Returns a new instance of Renderer.
5 6 7 8 |
# File 'lib/wicked_pdf/renderer.rb', line 5 def initialize(controller) @controller = controller @hf_tempfiles = [] end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
3 4 5 |
# File 'lib/wicked_pdf/renderer.rb', line 3 def controller @controller end |
Instance Method Details
#cleanup ⇒ Object
42 43 44 |
# File 'lib/wicked_pdf/renderer.rb', line 42 def cleanup clean_temp_files end |
#prepare(options) ⇒ Object
Renders the template and any header/footer templates WITHOUT invoking wkhtmltopdf, returning { html:, options: } suitable for Document#pdfs_from_strings. Header/footer tempfiles referenced by the returned options stay alive until #cleanup is called, which must happen after the PDFs have been generated.
Defaults (layout, template) match #render's render :pdf path, so a
prepared document converts identically to a single render.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/wicked_pdf/renderer.rb', line 29 def prepare() = WickedPdf.config..merge() [:basic_auth] = set_basic_auth() .delete(:pdf) [:layout] ||= false [:template] ||= File.join(controller.controller_path, controller.action_name) { html: controller.render_to_string(()), options: () } end |