-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Allow view template to be HTML #9
Open
mynameisnotbruce
wants to merge
6
commits into
igorkasyanchuk:master
Choose a base branch
from
mynameisnotbruce:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+3
−2
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The relaxed console command seems to rely on the file extension to decide how to treat a file
Heroku complains about unavailable sandboxes, this might fix it
Hi @igorkasyanchuk, The gem is not usable with Thanks. |
I think I'll, but I don't like this change --no-sandbox, I would like to see at configuration option Can you do it? |
Could we update to Rails 7 ? |
@revskill10 if you can help with upgrade it would be great |
Hi @igorkasyanchuk I have to make some changes to make it work, but it's a bit buggy. def render(&block)
controller = ActionController::Base.new
ctx = ActionView::LookupContext.new(ActionController::Base.view_paths)
view = ActionView::Base.new(ctx, {}, controller)
params = { file: @file, layout: @layout }
params = params.merge(locals: @locals) if @locals.present?
content = view.render(params)
template = ERB.new(content)
content = template.result
logger.debug "RailsPDF ====="
logger.debug "RailsPDF content:\n#{content}"
logger.debug "RailsPDF ====="
begin
input = BetterTempfile.new("in.pug")
output = BetterTempfile.new("out.pdf")
input.write(content)
input.flush
command = "#{RailsPDF.relaxed} #{input.path.to_s} #{output.path.to_s} --basedir / --build-once --no-sandbox"
stdin, stdout, wait_thr = Open3.popen2e(command, pgroup: true)
sleep(5)
pgid = Process.getpgid(wait_thr.pid)
Process.kill '-TERM', pgid
logger.debug "RailsPDF ===== #{command}"
output.rewind
output.binmode
data = output.read
yield(data)
ensure
input.try(:close!)
output.try(:close!)
end
end
```
1. I need to use ERB to render the template
2. I need to wait and kill child process (even with the --build-once arg, the relaxed process still watch for changes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relaxed treats input based on file extension (.pug vs .html), but previous code always created a temporary file "in.pug"; this could lead to relaxed treating HTML code as PUG code, resulting in errors. The change retains the view template's file extension for the temporary file and removes ".erb" if present.