Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sinatra + prawn example?

I'm in the dark here. What should I do to get this thing started?

This is the closest thing I've found to a solution, but it doesn't work for me. Sinatra: Template engine not found: prawn

Edit: I'm at a very very early stage. I literally want to just try to make a hello world in Prawn, and from there I'll add my content in. Something like this (app.rb):

require 'prawn'

get 'report/' do
content_type 'application/pdf'

pdf = Prawn::Document.new
pdf.text "Hello World"
pdf.render

end
like image 517
Daryll Santos Avatar asked Dec 25 '22 21:12

Daryll Santos


1 Answers

Your code works perfectly for me, except that I had to change the path from "report/" to "/report" (because that's what Sinatra sees when you go to

'http://localhost:4567/report/

).

The exact code that I ran is:

require 'sinatra'
require 'prawn'

get '/report/' do
  content_type 'application/pdf'

  pdf = Prawn::Document.new
  pdf.text "Hello World"
  pdf.render

end

and here's my ruby version:

ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.2.1]

I think you must be incredibly close.

like image 137
Andrew Bryant Avatar answered Jan 05 '23 08:01

Andrew Bryant