Class: Tilt::PDFTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/tilt/pdf.rb

Instance Method Summary collapse

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tilt/pdf.rb', line 14

def evaluate(scope, locals, &block)
  files = aux_files
  files << main_html_file
  render_to_tmp(*files, scope, locals, block) do |tmp|
    opts = pdfkit_options

    if header
      htmp = tmp.select { |_, f, _| f == header }.first[2]
      opts.merge!('header-html' => htmp) if header
    end

    if footer
      ftmp = tmp.select { |_, f, _| f == footer }.first[2]
      opts.merge!('footer-html' => ftmp) if footer
    end

    main = tmp.select { |_, f, _| f == main_html_file }.first[2]
    kit = PDFKit.new(File.read(main), opts)

    @output = kit.to_pdf
  end

  @output
end

#prepareObject



12
# File 'lib/tilt/pdf.rb', line 12

def prepare; end