Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

render_to_string with rtex

#3

There is no render_to_string with tex templates. It is not possible to do something like


a = render_to_string :template => 'projects/index.pdf.rtex'
send_data a, :type => 'application/pdf', :disposition => 'inline'

A possible solution is this new function in lib/rtex/framework/rails.rb


def render_to_string_with_rtex(options=nil, *args, &block)
  @internal_rtex_call = true
  result = render_to_string_without_rtex(options, *args, &block)
  @internal_rtex_call = nil
  if result.is_a?(String) && @template.template_format == :pdf
    options ||= {}
    ::RTeX::Document.new(result, options.merge(:processed => true)).to_pdf
  else
    result
  end
end

But this is not enough. render_to_string and send_data both call render to do the real work and render is mapped to render_with_rtex. And render_with_rtex will always generate a PDF if the template format is pdf. So the first if statement in render_with_rtex must be modified.

Old condition


if result.is_a?(String) && @template.template_format == :pdf

New condition


if result.is_a?(String) && @template.template_format == :pdf && @internal_rtex_call != true && result[0,5] != '%PDF-'

The modified version of lib/rtex/framework/rails.rb is attached to this ticket.

Reported by Hans-Jürgen Husel · June 26th, 2008 @ 02:34 PM

State: hold
Milestone: none
Assigned to: Bruce Williams Bruce Williams

Activity

  1. Joachim Garth
    Joachim Garth
    • Tag set to feature-request

    +1 Thanks! Just what I needed.

    August 9th, 2008 @ 04:27 PM

  2. Bruce Williams
    Bruce Williams
    • State changed from new to open

    Opening ticket for work, testing against stable and edge versions of Rails.

    August 17th, 2008 @ 04:16 PM

  3. Bruce Williams
    Bruce Williams
    • State changed from open to hold
    • Tag changed from feature-request to feature-request

    September 20th, 2008 @ 02:01 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.