Module: Prawnto::TemplateHandlers::Partials

Included in:
Renderer
Defined in:
lib/prawnto/template_handlers/partials.rb

Instance Method Summary collapse

Instance Method Details

#partial!(partial_name, prawn_object = pdf) ⇒ Object

Can be called within a prawn template to render a partial below it. :partial_name - Current has to be the entire path from the views folder. Doesn’t recognize the folder of the

current template.

:prawn_object - The object to use for the pdf object in the partial.

Defaults to the pdf document, but can take a paramenter to render within a prawn object. This
is good for items like tables, text_blocks, etc.


11
12
13
14
15
16
17
# File 'lib/prawnto/template_handlers/partials.rb', line 11

def partial!(partial_name, prawn_object = pdf)
  @pdf_stack ||= []
  @pdf_stack.push @pdf
  @pdf = prawn_object
  instance_eval partial_source(partial_name)
  @pdf = @pdf_stack.pop
end