hiccdown 1.2.1 → 1.3.0

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: f176ea8bf71818e2dcf2e3c6c011639e68fcae488c0b9c488e19900a7739957c
4
- data.tar.gz: c54d3c82e6425a03d2579d864f7d857dd21084b6d72119b57fffe9dd941fe027
3
+ metadata.gz: 2e16c613ff62cbd88fb53d8c57c4f9e4a89a06f498e8344fe67f6da3f82ada33
4
+ data.tar.gz: 0f32c9b93fde68cf68544fb10a0b1285c0799779245af8b2d91efc066342a248
5
5
  SHA512:
6
- metadata.gz: 4b163285641c753cb155824b7673fd3e6d4da312c20dfe4743e68523bfab54a54e46c95215ba0667659538ba552f593c1fd07f6bd6c672e80232d418251b75c3
7
- data.tar.gz: 378ce99f489b180130c2fc0b076d603f06cd1370763082f0252c78b6ea8bb63547ca4c58ce8172ed598b8502f2abd01b8951aa4b7b18433653dd58ac6075a31c
6
+ metadata.gz: 686df3dded370832f8d74169dd9fe54fce9ee45b8c9c30c89dd7dc8ab3d8876c9fbf205b37815ea08a133229c01fb091b26c6884126f3e52d7b0047d5b1f48d9
7
+ data.tar.gz: 0eb3af3931eb0b91484ea462399702c85fbb29649e3a38a52ac3c7266e5bd2ca43e4f5328fd398fc5775dd9a4099853330f5d759321a822a5c52f9c4801d0ccf
@@ -52,6 +52,10 @@ module Hiccdown
52
52
  elsif options.key?(:action) || args.first.is_a?(Symbol) || (args.first.is_a?(String) && !args.first.include?('/'))
53
53
  action_name = options[:action] || args.first.to_s
54
54
  render_helper_method(action_name, options)
55
+ # When a template is given but doesn’t exist. Useful for gems like High Voltage
56
+ elsif options.key?(:template) && !view_context.lookup_context.template_exists?(options[:template])
57
+ action_name = options[:template].split('/').last
58
+ render_helper_method(action_name, options)
55
59
  # Partials, files and all other cases
56
60
  else
57
61
  original_render(*args, options)
data/lib/hiccdown.rb CHANGED
@@ -14,19 +14,17 @@ module Hiccdown
14
14
 
15
15
  module MethodOverrides
16
16
  def self.prepended(base)
17
- # button_to and link_to use content_tag internally so need no explicit mention.
18
- # TODO: form_for and form_with use `tag` (https://apidock.com/rails/ActionView/Helpers/TagHelper/tag)
19
- # Any way to override that instead?
20
- [:content_tag, :form_for, :form_with].each do |method_name|
21
- define_method(method_name) do |*args, **kwargs, &block|
22
- if block
23
- super(*args, **kwargs) do |*brgs, **jwargs|
24
- result = block.call(*brgs, *jwargs)
25
- result.is_a?(Array) ? Hiccdown::to_html(result).html_safe : result
26
- end
27
- else
28
- super(*args, **kwargs)
17
+ # `capture` is at the root of seemingly all Rails methods tasked with
18
+ # rendering content, including `content_tag` and `tag`, which in turn
19
+ # are used for `link_to`, `form_for`, etc.
20
+ define_method(:capture) do |*args, **kwargs, &block|
21
+ if block
22
+ super(*args, **kwargs) do |*brgs, **jwargs|
23
+ result = block.call(*brgs, *jwargs)
24
+ result.is_a?(Array) ? Hiccdown::to_html(result).html_safe : result
29
25
  end
26
+ else
27
+ super(*args, **kwargs)
30
28
  end
31
29
  end
32
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiccdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Hackethal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-24 00:00:00.000000000 Z
11
+ date: 2024-07-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generates an HTML string from a Hiccup structure and improves Rails views.
14
14
  email: engineering@dennishackethal.com