Class: Baren::PjsTemplate

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/baren.rb

Instance Method Summary collapse

Instance Method Details

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



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/baren.rb', line 25

def evaluate(scope, locals, &block)
  require "tempfile"
  dataURL = Tempfile.open("pjs2png") do |f|
    f.print Tilt.new(PhantomJs.pjs2png_path).render(nil, :pjs => data.inspect, :processingjs => File.read(ProcessingJs.path).inspect)
    f.flush
    cmd = "#{PhantomJs.path} #{f.path}"
    `#{cmd}`
  end
  require "base64"
  @output ||= Base64.decode64(dataURL[%r"data:image/png;base64,(.*)",1])
end

#prepareObject

self.default_mime_type = ‘image/png’



22
23
# File 'lib/baren.rb', line 22

def prepare
end