ruby2html 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/app/components/first_component.rb +4 -0
- data/app/components/third_component/third_component.html.rb +3 -0
- data/app/views/home/rb_files.html.rb +4 -1
- data/app/views/shared/_footer.html.rb +3 -0
- data/config/environments/development.rb +2 -0
- data/lib/gem/ruby2html/railtie.rb +2 -2
- data/lib/gem/ruby2html/render.rb +14 -0
- data/lib/gem/ruby2html/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e39b469662602b3df3e2444c58474a8c412a90d3556de30c5d404e41f4358eb8
|
4
|
+
data.tar.gz: dbd03a556e2deebf9d795065de00768259c21dc76d9d248a1a6799c80faa5434
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edc9f77f24cdcc0cedd73f42750989abf6edf4df55ff40114d2543b2e895fa338caadbe9cea0e99f46a4b2f8c32ef42997e543a7e309ed8781181240e12d05e9
|
7
|
+
data.tar.gz: dbc116c78d40ce02a5ce228993e8803ad3afd64d43aabc543a1aa4ec407c4fa93b5d1192d9268f832b6a86bbe313e5df2faa878f0e1ec951a1741c0d3dd8f792
|
data/README.md
CHANGED
@@ -49,6 +49,13 @@ plain '<div>Inline html</div>'.html_safe
|
|
49
49
|
render partial: 'shared/navbar'
|
50
50
|
```
|
51
51
|
|
52
|
+
### (Optional) Nicely Format the HTML
|
53
|
+
|
54
|
+
File: `config/environments/development.rb` or `config/environments/test.rb`
|
55
|
+
```ruby
|
56
|
+
config.middleware.use Ruby2html::HtmlBeautifierMiddleware
|
57
|
+
```
|
58
|
+
|
52
59
|
#### Or use your current .erb views
|
53
60
|
|
54
61
|
### In your ApplicationController
|
@@ -9,7 +9,7 @@ module Ruby2html
|
|
9
9
|
new.call(template, source)
|
10
10
|
end
|
11
11
|
|
12
|
-
def call(
|
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.
|
20
|
+
renderer.render_from_rails(#{template.identifier.inspect})
|
21
21
|
ensure
|
22
22
|
Thread.current[:__ruby2html_renderer__] = previous_renderer
|
23
23
|
end
|
data/lib/gem/ruby2html/render.rb
CHANGED
@@ -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
|
|
@@ -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))
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
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-
|
12
|
-
dependencies:
|
11
|
+
date: 2024-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: htmlbeautifier
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
13
27
|
description: Ruby2HTML empowers developers to write view logic in pure Ruby, seamlessly
|
14
28
|
converting it into clean, well-formatted HTML. Enhance your templating workflow,
|
15
29
|
improve readability, and leverage the full power of Ruby in your views. Features
|
@@ -56,6 +70,7 @@ files:
|
|
56
70
|
- app/views/layouts/mailer.text.erb
|
57
71
|
- app/views/pwa/manifest.json.erb
|
58
72
|
- app/views/pwa/service-worker.js
|
73
|
+
- app/views/shared/_footer.html.rb
|
59
74
|
- app/views/shared/_navbar.html.erb
|
60
75
|
- config.ru
|
61
76
|
- config/application.rb
|