title: Sinatra render a ruby file
body: <p>How to render a ruby file (which in my case returns a pdf document) for example:</p>
  
  <pre><code> get "/pdf" do
    @locals = {some_locals_hash}
    headers({'Content-Type' =&gt; 'application/pdf',
      'Content-Description' =&gt; 'File Transfer',
      'Content-Transfer-Encoding' =&gt; 'binary',
      'Content-Disposition' =&gt; "attachment;filename=\"test.pdf\"",
      'Expires' =&gt; '0',
      'Pragma' =&gt; 'public'})
    ruby :test, :layout =&gt; false, :locals =&gt; @locals
   end
  </code></pre>
  
  <p>I know Tilt does not have ruby template. For now I put all content in a <code>*.haml</code> file like:</p>
  
  <pre><code> -# PDF file description
   :ruby
     pdf = Prawn::Document.new(
       ... docs settings)
       ... docs content
     end
   = pdf.render()
  </code></pre>
  
  <p>and I render it with <code>haml :template ...etc...</code></p>
  
  <p>Truth is, I only need this for syntax highlighting, my editor does not properly highlight embedded ruby code in haml files :(. So if it's to complicated don't bother...</p>