-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Layout not used while using render_to_string #249
Comments
There is a section in the readme describing this. See https://github.com/Studiosity/grover?tab=readme-ov-file#relative-paths Your HTML is very likely going to be using relative paths. Consider how the browser driven by grover is going to know how to resolve those relative paths 😉 Sure fire way to test this.. dump the rendered HTML to a file.. open the file in a browser. Do you get the same result? (hint.. yep!) |
Thanks for your reply, I did output the rendered html to file and it just contains the contents of the method.html.erb and doesn't include layout contents. I'm a noob and didn't understand how to fix it. Also, one more thing to ask here, I setup grover by creating an initializer file with some options. I wasn't able to make it run using Rails 7 by adding the middleware part in application.rb (I get UnknownFormat exception) when I add the following to application.rb
Exception: My Request: It works without the middleware part though but doesn't render layout while generating pdf. Can you please guide if I am missing something on my side? |
Using |
I'm using grover to generate a pdf file (using tailwindcss). Here's the code snippet
html = render_to_string(template: 'controller_name/method_name', layout: 'pdf')
pdf = Grover.new(html).to_pdf
send_data pdf, filename: 'report.pdf', type: 'application/pdf', disposition: 'inline'
I've the application/tailwindcss in pdf layout. But rendering above only renders the contents of method template without using layout. Can you please guide how to use layout
The text was updated successfully, but these errors were encountered: