sghtmltopdf 0.6.0-aarch64-linux → 0.6.1-aarch64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c5f867f2c49425f42c69a26ca06a40ec0fc4e4e3f87ccd60bf12873fefd4b67
4
- data.tar.gz: c6f46e1f4a5e60c04e08b2e41b41aa341397d3139f56ccd9e8477e58a9f3036d
3
+ metadata.gz: c096aac7e911b6b8973eca4ffeedd3062bcffd9f07dddada073da979bc2d5747
4
+ data.tar.gz: 27be2c0d59a710383ab875bb4ce084353791ca15d9c5575087945ba5929d946c
5
5
  SHA512:
6
- metadata.gz: 53096585b732d37dc882030d1cd9d017b82c8c2ad5c0443a7f8519fd90ee3666198947c283ae2e83b107f5c3b79fad4c84553b24cc07f858d58b81b42ce1a112
7
- data.tar.gz: 9487e0ff7bf48fe1aee3130e099df4a13445984cbcd8301ff11ac59d8270ad92799c7bdaf5238797e331cd1957e171996e89d027bbb479e94a1c2d6ae137073a
6
+ metadata.gz: 9cbe4f4d889f9964a31ff1e5794432d91bc3ab672a2106a9e4e6900255561f5acec42f69da259c5de9184f58eec4d1aeb726c818878b1729ccf1ea1346966395
7
+ data.tar.gz: ec4caf9af68bb791cc07206c579a6d62ec99970ab98a1eddf78d2605a2bb6ba8c9d2ae4ee94789e4d6f87b89e18ec24604fdd748982311eed2882493bcc75359
data/README.md CHANGED
@@ -89,6 +89,8 @@ end
89
89
  ```
90
90
 
91
91
  View-rendering keys (`template`, `layout`, `locals`, …) go to `render_to_string`, response keys (`filename`, `disposition`, `status`) go to `send_data`, `show_as_html: true` returns the HTML instead of a PDF, and everything else is passed to the converter.
92
+
93
+ `render_to_string(pdf: "invoice", template: "invoices/show")` returns PDF bytes without setting the controller response. You can then pass those bytes to `send_data` or save them elsewhere; response options such as `filename`, `disposition`, and `status` only apply to `render pdf:`.
92
94
  Converter keys are flat CLI flag names, so wicked_pdf's nested `margin: {top: 10}` becomes `margin_top: "10mm"` (with the unit spelled out); the [migration guide](https://waka.github.io/sghtmltopdf/en/migration/wicked-pdf.html) maps every key one by one.
93
95
 
94
96
  ### Assets
Binary file
Binary file
Binary file
Binary file
@@ -10,6 +10,19 @@ module Sghtmltopdf
10
10
  #
11
11
  # It is a pure Ruby class with no dependency on Rails, so it can be unit tested without Rails.
12
12
  class Renderer
13
+ module RenderToString
14
+ def render_to_string(*args, &block)
15
+ options = args.first.is_a?(Hash) ? args.first : args[1]
16
+ return super unless options.is_a?(Hash) && options.key?(:pdf)
17
+
18
+ normalized_args = args.map { |arg| arg.is_a?(Hash) ? arg.dup : arg }
19
+ options = _normalize_args(*normalized_args, &block)
20
+ renderer = Renderer.new(options.delete(:pdf), options, default_name: action_name)
21
+ html = super(**renderer.render_options, &block)
22
+ renderer.body_for(html)
23
+ end
24
+ end
25
+
13
26
  # The keys passed straight to `render_to_string`.
14
27
  RAILS_RENDER_KEYS = %i[
15
28
  action assigns body collection file formats handlers html inline layout
@@ -39,6 +52,7 @@ module Sghtmltopdf
39
52
  # Register the renderer with `ActionController::Renderers.add(:pdf)`.
40
53
  # Called from the Railtie's Action Controller load hook (`on_load`).
41
54
  def self.register!
55
+ ::ActionController::Rendering.prepend(RenderToString)
42
56
  ::ActionController::Renderers.add(:pdf) do |name, options|
43
57
  renderer = ::Sghtmltopdf::Renderer.new(name, options, default_name: action_name)
44
58
  html = render_to_string(**renderer.render_options)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sghtmltopdf
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sghtmltopdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - yo_waka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-18 00:00:00.000000000 Z
11
+ date: 2026-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Ruby binding for sghtmltopdf, a successor to wkhtmltopdf: an HTML-to-PDF