ruby2html 1.3.1 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 379258f81cef17450f4024d02db4dd0ddd3e2bf82b6e49c80d7c56d2bd935425
4
- data.tar.gz: 7f0f351fa20e636e8f0fe1abbe26e964428bccafee8e42d7d4a54aa374ce44cc
3
+ metadata.gz: bb194a11e2015f7caf7e2994f5db0c67fa9b8967c2e44906b3a036aba9eb1be6
4
+ data.tar.gz: e60ff3a75bc735e3b084d0f3b91503f151564f3c9d82c9721e8dbc281d6c2283
5
5
  SHA512:
6
- metadata.gz: 0744010717f690632ea0c5fd8042cae5fc84eb31d00b65ec3f153a0cce6e2f523750ff23ec6b46d028bc215844137f3a4b35ce0a1370250a3f9f275527e058e6
7
- data.tar.gz: dd934691897d726bed26a73bfecf61d515a780ee7ba45471a2efdaf0848156b6afa918e9d45ef9f9dd8231cb032bd9f4cef040befafd3abe888c228526321ef6
6
+ metadata.gz: bea7e7d8965f80fdf3aed3f92ecbc49f14630da3e832dae868836cfdcf1f60f8a439e3a82c850586462fa68adb3a39dcc58d35821a7b9554e3df8e8115083a33
7
+ data.tar.gz: ba619ce95c33e4d96579bc4f423b2554a75160d11102d9f55dee7632ad7eb63d3e20bd21c3aaee4402a861e9f2e5b8a20aa08c03e3086654dec71072d42ff0f7
@@ -6,6 +6,10 @@ class FirstComponent < ApplicationComponent
6
6
  end
7
7
 
8
8
  def another_div
9
+ div do
10
+ "Item value: #{@item}"
11
+ end
12
+
9
13
  div class: 'another' do
10
14
  h2 'Another subheading from component'
11
15
  end
@@ -1,3 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  h1 'Third component'
4
+ div do
5
+ "Item value: #{@item}"
6
+ end
@@ -8,3 +8,6 @@ div @value
8
8
 
9
9
  link_to 'Home', root_url
10
10
  render partial: 'shared/navbar'
11
+ render partial: 'shared/footer'
12
+
13
+ div @value
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ h1 'footer'
@@ -9,7 +9,7 @@ module Ruby2html
9
9
  new.call(template, source)
10
10
  end
11
11
 
12
- def call(_template, source)
12
+ def call(template, source)
13
13
  <<-RUBY
14
14
  begin
15
15
  previous_renderer = Thread.current[:__ruby2html_renderer__]
@@ -17,7 +17,7 @@ module Ruby2html
17
17
  #{source}
18
18
  end
19
19
  Thread.current[:__ruby2html_renderer__] = renderer
20
- renderer.render
20
+ renderer.render_from_rails(#{template.identifier.inspect})
21
21
  ensure
22
22
  Thread.current[:__ruby2html_renderer__] = previous_renderer
23
23
  end
@@ -28,6 +28,15 @@ module Ruby2html
28
28
  @current_output = @output
29
29
  end
30
30
 
31
+ def render_from_rails(template_path)
32
+ result = render
33
+ return result unless annotate_rendered_view_with_filenames?
34
+
35
+ template_path = template_path.sub("#{Rails.root}/", '')
36
+
37
+ "<!-- BEGIN #{template_path} -->#{result}<!-- END #{template_path} -->".html_safe
38
+ end
39
+
31
40
  def render(*args, **options, &block)
32
41
  set_instance_variables
33
42
 
@@ -99,9 +108,9 @@ module Ruby2html
99
108
  end
100
109
 
101
110
  private
102
- def method_missing(method_name, *args, &block)
111
+ def method_missing(method_name, *args, **options, &block)
103
112
  if @context.respond_to?(method_name)
104
- @context.send(method_name, *args, &block)
113
+ @context.send(method_name, *args, **options, &block)
105
114
  else
106
115
  super
107
116
  end
@@ -135,6 +144,11 @@ module Ruby2html
135
144
  CGI.escapeHTML(text.to_s)
136
145
  end
137
146
 
147
+ def annotate_rendered_view_with_filenames?
148
+ return @annotate_rendered_view_with_filenames if defined?(@annotate_rendered_view_with_filenames)
149
+ @annotate_rendered_view_with_filenames = Rails.application.config.action_view.annotate_rendered_view_with_filenames
150
+ end
151
+
138
152
  def set_instance_variables
139
153
  @context.instance_variables.each do |name|
140
154
  instance_variable_set(name, @context.instance_variable_get(name))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ruby2html
4
- VERSION = '1.3.1'
4
+ VERSION = '1.3.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sebi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-09 00:00:00.000000000 Z
11
+ date: 2024-08-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby2HTML empowers developers to write view logic in pure Ruby, seamlessly
14
14
  converting it into clean, well-formatted HTML. Enhance your templating workflow,
@@ -56,6 +56,7 @@ files:
56
56
  - app/views/layouts/mailer.text.erb
57
57
  - app/views/pwa/manifest.json.erb
58
58
  - app/views/pwa/service-worker.js
59
+ - app/views/shared/_footer.html.rb
59
60
  - app/views/shared/_navbar.html.erb
60
61
  - config.ru
61
62
  - config/application.rb