ruby2html 1.5.2 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gem/ruby2html/render.rb +1 -1
  3. data/lib/gem/ruby2html/version.rb +1 -1
  4. data/ruby2html.gemspec +33 -0
  5. metadata +2 -76
  6. data/.dockerignore +0 -48
  7. data/.rspec +0 -2
  8. data/.rubocop.yml +0 -16
  9. data/.ruby-version +0 -1
  10. data/Dockerfile +0 -71
  11. data/README.md +0 -318
  12. data/Rakefile +0 -8
  13. data/app/assets/config/manifest.js +0 -2
  14. data/app/assets/images/.keep +0 -0
  15. data/app/assets/stylesheets/application.css +0 -15
  16. data/app/channels/application_cable/channel.rb +0 -6
  17. data/app/channels/application_cable/connection.rb +0 -6
  18. data/app/components/application_component.rb +0 -5
  19. data/app/components/first_component.html.rb +0 -11
  20. data/app/components/first_component.rb +0 -19
  21. data/app/components/second_component.rb +0 -12
  22. data/app/components/third_component/third_component.html.rb +0 -6
  23. data/app/components/third_component.rb +0 -7
  24. data/app/controllers/application_controller.rb +0 -7
  25. data/app/controllers/benchmark_controller.rb +0 -48
  26. data/app/controllers/concerns/.keep +0 -0
  27. data/app/controllers/home_controller.rb +0 -16
  28. data/app/helpers/application_helper.rb +0 -4
  29. data/app/jobs/application_job.rb +0 -9
  30. data/app/mailers/application_mailer.rb +0 -6
  31. data/app/models/application_record.rb +0 -5
  32. data/app/models/concerns/.keep +0 -0
  33. data/app/views/benchmark/normal_html.html.erb +0 -31
  34. data/app/views/benchmark/ruby_2html.html.rb +0 -33
  35. data/app/views/home/form.html.rb +0 -14
  36. data/app/views/home/index.html.erb +0 -43
  37. data/app/views/home/rb_files.html.rb +0 -18
  38. data/app/views/layouts/application.html.erb +0 -21
  39. data/app/views/layouts/mailer.html.erb +0 -13
  40. data/app/views/layouts/mailer.text.erb +0 -1
  41. data/app/views/pwa/manifest.json.erb +0 -22
  42. data/app/views/pwa/service-worker.js +0 -26
  43. data/app/views/shared/_footer.html.rb +0 -3
  44. data/app/views/shared/_navbar.html.erb +0 -1
  45. data/config/application.rb +0 -45
  46. data/config/boot.rb +0 -6
  47. data/config/cable.yml +0 -10
  48. data/config/credentials.yml.enc +0 -1
  49. data/config/database.yml +0 -32
  50. data/config/environment.rb +0 -7
  51. data/config/environments/development.rb +0 -85
  52. data/config/environments/production.rb +0 -104
  53. data/config/environments/test.rb +0 -69
  54. data/config/initializers/assets.rb +0 -14
  55. data/config/initializers/content_security_policy.rb +0 -27
  56. data/config/initializers/filter_parameter_logging.rb +0 -10
  57. data/config/initializers/inflections.rb +0 -18
  58. data/config/initializers/permissions_policy.rb +0 -15
  59. data/config/locales/en.yml +0 -31
  60. data/config/puma.rb +0 -56
  61. data/config/routes.rb +0 -23
  62. data/config/storage.yml +0 -34
  63. data/config.ru +0 -8
  64. data/db/seeds.rb +0 -11
  65. data/lefthook.yml +0 -8
  66. data/lib/assets/.keep +0 -0
  67. data/lib/tasks/.keep +0 -0
  68. data/log/.keep +0 -0
  69. data/public/404.html +0 -67
  70. data/public/406-unsupported-browser.html +0 -66
  71. data/public/422.html +0 -67
  72. data/public/500.html +0 -66
  73. data/public/icon.png +0 -0
  74. data/public/icon.svg +0 -3
  75. data/public/robots.txt +0 -1
  76. data/storage/.keep +0 -0
  77. data/tmp/.keep +0 -0
  78. data/tmp/pids/.keep +0 -0
  79. data/tmp/storage/.keep +0 -0
  80. data/vendor/.keep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6939967de3aa7a534e6ae8d5736e9b8aada0e7bb8822e8acb2a7be2a072c6f82
4
- data.tar.gz: b872fcd0fa941c7f09bf41a3b3cece4b53d765d060afa9bbde4b88c8ed786ecd
3
+ metadata.gz: a7e4ace849a6799ec0dd9c793678a6eefcf62c1b0ccf8ed2de53a4d3c18c352a
4
+ data.tar.gz: cad377858ea7819014d67638191d1b22567584796e7372212c7a2dcd90046196
5
5
  SHA512:
6
- metadata.gz: 7c0e095450fbdb205a1ea30ea67fc2b9a7a84a8336b78b80b2d7426efb05d75cddaa600161e2bc1cf2ee68710cdbc3b2c164555b32e969c01ef80badd2f59e99
7
- data.tar.gz: 78e35ea7e89947b3ba9b0e48171539895b2968149ddaabe86b64d87593940ded7cb03e8adac144c2c1d513928c84ccac5739a185ec977a1caadd16d3114f4e01
6
+ metadata.gz: 34aef0821511553c2ef86498f9adf10d42668cd3a04cadbde09adfc79eb4410220932d3ff99dc22261119a6efd7e20914b791c5ecca546564e3cb4a6b870b594
7
+ data.tar.gz: a1afad1a03be0bd3cadcd901fb34193007eb490ec619717d1550e4d63f72718a630e656021ad8dc39ba52e03759a839203b93b7d271f249b4a0476dfa9eae7d4
@@ -12,7 +12,7 @@ module Ruby2html
12
12
  kbd label legend li link main map mark meta meter nav noscript object ol optgroup option
13
13
  output p param picture pre progress q rp rt ruby s samp script section select small source
14
14
  span strong style sub summary sup table tbody td template textarea tfoot th thead time title
15
- tr track u ul var video wbr turbo-frame
15
+ tr track u ul var video wbr turbo-frame turbo-stream
16
16
  ].freeze
17
17
 
18
18
  VOID_ELEMENTS = %w[area base br col embed hr img input link meta param source track wbr].freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ruby2html
4
- VERSION = '1.5.2'
4
+ VERSION = '1.5.4'
5
5
  end
data/ruby2html.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/gem/ruby2html/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'ruby2html'
7
+ spec.version = Ruby2html::VERSION
8
+ spec.authors = ['sebi']
9
+ spec.email = ['gore.sebyx@yahoo.com']
10
+
11
+ spec.summary = 'Transform Ruby code into beautiful, structured HTML'
12
+ spec.description = 'Ruby2HTML empowers developers to write view logic in pure Ruby, ' \
13
+ 'seamlessly converting it into clean, well-formatted HTML. ' \
14
+ 'Enhance your templating workflow, improve readability, and ' \
15
+ 'leverage the full power of Ruby in your views. ' \
16
+ 'Features include Rails integration, custom component support, ' \
17
+ 'and automatic HTML beautification.'
18
+ spec.homepage = 'https://github.com/sebyx07/ruby2html'
19
+ spec.license = 'MIT'
20
+ spec.required_ruby_version = '>= 3.0.0'
21
+
22
+ spec.metadata['homepage_uri'] = spec.homepage
23
+ spec.metadata['source_code_uri'] = spec.homepage
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ gemspec = File.basename(__FILE__)
28
+
29
+ spec.files = Dir.glob('{lib}/gem/**/*') + [gemspec]
30
+ spec.require_paths = ['lib/gem']
31
+
32
+ spec.add_dependency 'htmlbeautifier', '>= 1.4'
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - sebi
@@ -34,67 +34,6 @@ executables: []
34
34
  extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
- - ".dockerignore"
38
- - ".rspec"
39
- - ".rubocop.yml"
40
- - ".ruby-version"
41
- - Dockerfile
42
- - README.md
43
- - Rakefile
44
- - app/assets/config/manifest.js
45
- - app/assets/images/.keep
46
- - app/assets/stylesheets/application.css
47
- - app/channels/application_cable/channel.rb
48
- - app/channels/application_cable/connection.rb
49
- - app/components/application_component.rb
50
- - app/components/first_component.html.rb
51
- - app/components/first_component.rb
52
- - app/components/second_component.rb
53
- - app/components/third_component.rb
54
- - app/components/third_component/third_component.html.rb
55
- - app/controllers/application_controller.rb
56
- - app/controllers/benchmark_controller.rb
57
- - app/controllers/concerns/.keep
58
- - app/controllers/home_controller.rb
59
- - app/helpers/application_helper.rb
60
- - app/jobs/application_job.rb
61
- - app/mailers/application_mailer.rb
62
- - app/models/application_record.rb
63
- - app/models/concerns/.keep
64
- - app/views/benchmark/normal_html.html.erb
65
- - app/views/benchmark/ruby_2html.html.rb
66
- - app/views/home/form.html.rb
67
- - app/views/home/index.html.erb
68
- - app/views/home/rb_files.html.rb
69
- - app/views/layouts/application.html.erb
70
- - app/views/layouts/mailer.html.erb
71
- - app/views/layouts/mailer.text.erb
72
- - app/views/pwa/manifest.json.erb
73
- - app/views/pwa/service-worker.js
74
- - app/views/shared/_footer.html.rb
75
- - app/views/shared/_navbar.html.erb
76
- - config.ru
77
- - config/application.rb
78
- - config/boot.rb
79
- - config/cable.yml
80
- - config/credentials.yml.enc
81
- - config/database.yml
82
- - config/environment.rb
83
- - config/environments/development.rb
84
- - config/environments/production.rb
85
- - config/environments/test.rb
86
- - config/initializers/assets.rb
87
- - config/initializers/content_security_policy.rb
88
- - config/initializers/filter_parameter_logging.rb
89
- - config/initializers/inflections.rb
90
- - config/initializers/permissions_policy.rb
91
- - config/locales/en.yml
92
- - config/puma.rb
93
- - config/routes.rb
94
- - config/storage.yml
95
- - db/seeds.rb
96
- - lefthook.yml
97
- - lib/assets/.keep
98
37
  - lib/gem/ruby2html.rb
99
38
  - lib/gem/ruby2html/component_helper.rb
100
39
  - lib/gem/ruby2html/html_beautifier_middleware.rb
@@ -107,20 +46,7 @@ files:
107
46
  - lib/gem/ruby2html/railtie.rb
108
47
  - lib/gem/ruby2html/render.rb
109
48
  - lib/gem/ruby2html/version.rb
110
- - lib/tasks/.keep
111
- - log/.keep
112
- - public/404.html
113
- - public/406-unsupported-browser.html
114
- - public/422.html
115
- - public/500.html
116
- - public/icon.png
117
- - public/icon.svg
118
- - public/robots.txt
119
- - storage/.keep
120
- - tmp/.keep
121
- - tmp/pids/.keep
122
- - tmp/storage/.keep
123
- - vendor/.keep
49
+ - ruby2html.gemspec
124
50
  homepage: https://github.com/sebyx07/ruby2html
125
51
  licenses:
126
52
  - MIT
data/.dockerignore DELETED
@@ -1,48 +0,0 @@
1
- # See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2
-
3
- # Ignore git directory.
4
- /.git/
5
- /.gitignore
6
-
7
- # Ignore bundler config.
8
- /.bundle
9
-
10
- # Ignore all environment files (except templates).
11
- /.env*
12
- !/.env*.erb
13
-
14
- # Ignore all default key files.
15
- /config/master.key
16
- /config/credentials/*.key
17
-
18
- # Ignore all logfiles and tempfiles.
19
- /log/*
20
- /tmp/*
21
- !/log/.keep
22
- !/tmp/.keep
23
-
24
- # Ignore pidfiles, but keep the directory.
25
- /tmp/pids/*
26
- !/tmp/pids/.keep
27
-
28
- # Ignore storage (uploaded files in development and any SQLite databases).
29
- /storage/*
30
- !/storage/.keep
31
- /tmp/storage/*
32
- !/tmp/storage/.keep
33
-
34
- # Ignore assets.
35
- /node_modules/
36
- /app/assets/builds/*
37
- !/app/assets/builds/.keep
38
- /public/assets
39
-
40
- # Ignore CI service files.
41
- /.github
42
-
43
- # Ignore development files
44
- /.devcontainer
45
-
46
- # Ignore Docker-related files
47
- /.dockerignore
48
- /Dockerfile*
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --require spec_helper
2
- --format progress
data/.rubocop.yml DELETED
@@ -1,16 +0,0 @@
1
- inherit_gem:
2
- rubocop-rails_config:
3
- - config/rails.yml
4
-
5
- AllCops:
6
- TargetRubyVersion: 3.0
7
-
8
- Style/ClassAndModuleChildren:
9
- EnforcedStyle: nested
10
-
11
- Lint/Debugger:
12
- Enabled: true
13
-
14
- Style/StringLiterals:
15
- Enabled: true
16
- EnforcedStyle: single_quotes
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.3.3
data/Dockerfile DELETED
@@ -1,71 +0,0 @@
1
- # syntax = docker/dockerfile:1
2
-
3
- # This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
4
- # docker build -t my-app .
5
- # docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY=<value from config/master.key> my-app
6
-
7
- # For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html
8
-
9
- # Make sure RUBY_VERSION matches the Ruby version in .ruby-version
10
- ARG RUBY_VERSION=3.3.3
11
- FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
12
-
13
- # Rails app lives here
14
- WORKDIR /rails
15
-
16
- # Install base packages
17
- RUN apt-get update -qq && \
18
- apt-get install --no-install-recommends -y curl libjemalloc2 libsqlite3-0 libvips && \
19
- rm -rf /var/lib/apt/lists /var/cache/apt/archives
20
-
21
- # Set production environment
22
- ENV RAILS_ENV="production" \
23
- BUNDLE_DEPLOYMENT="1" \
24
- BUNDLE_PATH="/usr/local/bundle" \
25
- BUNDLE_WITHOUT="development"
26
-
27
- # Throw-away build stage to reduce size of final image
28
- FROM base AS build
29
-
30
- # Install packages needed to build gems
31
- RUN apt-get update -qq && \
32
- apt-get install --no-install-recommends -y build-essential git pkg-config && \
33
- rm -rf /var/lib/apt/lists /var/cache/apt/archives
34
-
35
- # Install application gems
36
- COPY Gemfile Gemfile.lock ./
37
- RUN bundle install && \
38
- rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
39
- bundle exec bootsnap precompile --gemfile
40
-
41
- # Copy application code
42
- COPY . .
43
-
44
- # Precompile bootsnap code for faster boot times
45
- RUN bundle exec bootsnap precompile app/ lib/
46
-
47
- # Precompiling assets for production without requiring secret RAILS_MASTER_KEY
48
- RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
49
-
50
-
51
-
52
-
53
- # Final stage for app image
54
- FROM base
55
-
56
- # Copy built artifacts: gems, application
57
- COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
58
- COPY --from=build /rails /rails
59
-
60
- # Run and own only the runtime files as a non-root user for security
61
- RUN groupadd --system --gid 1000 rails && \
62
- useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
63
- chown -R rails:rails db log storage tmp
64
- USER 1000:1000
65
-
66
- # Entrypoint prepares the database.
67
- ENTRYPOINT ["/rails/bin/docker-entrypoint"]
68
-
69
- # Start the server by default, this can be overwritten at runtime
70
- EXPOSE 3000
71
- CMD ["./bin/rails", "server"]
data/README.md DELETED
@@ -1,318 +0,0 @@
1
- # Ruby2html 🔮✨
2
-
3
- Transform your view logic into elegant, semantic HTML with the power of pure Ruby! 🚀✨
4
-
5
- ## 🌟 What is Ruby2html?
6
-
7
- Ruby2html is a magical gem that allows you to write your views in pure Ruby and automatically converts them into clean, well-formatted HTML. Say goodbye to messy ERB templates and hello to the full power of Ruby in your views! 🎉
8
-
9
- ## 🚀 Installation
10
-
11
- Add this line to your application's Gemfile:
12
-
13
-
14
- ```ruby
15
- gem 'ruby2html'
16
- ```
17
-
18
- And then execute:
19
-
20
- $ bundle install
21
-
22
- Or install it yourself as:
23
-
24
- $ gem install ruby2html
25
-
26
- ## 🎨 Usage
27
-
28
- ### In your views
29
-
30
- File: `app/views/your_view.html.rb`
31
-
32
- ```ruby
33
- div class: 'container' do
34
- h1 'Welcome to Ruby2html! 🎉', class: 'main-title', 'data-controller': 'welcome'
35
- link_to 'Home Sweet Home 🏠', root_path, class: 'btn btn-primary', 'data-turbo': false
36
-
37
- @products.each do |product|
38
- h2 class: 'item-title', id: "product-#{product[:id]}" do
39
- product.title
40
- end
41
- p class: 'item-description' do
42
- product.description
43
- end
44
- end
45
- end
46
-
47
- plain '<div>Inline html</div>'.html_safe
48
-
49
- render partial: 'shared/navbar'
50
- ```
51
-
52
- ### (Optional) Nicely Format the HTML for source inspection
53
-
54
- File: `config/environments/development.rb` or `config/environments/test.rb`
55
- ```ruby
56
- config.middleware.use Ruby2html::HtmlBeautifierMiddleware
57
- ```
58
-
59
- #### Or use your current .erb views
60
-
61
- ### In your ApplicationController
62
-
63
- File: `app/controllers/application_controller.rb`
64
-
65
- ```ruby
66
- # frozen_string_literal: true
67
-
68
- class ApplicationController < ActionController::Base
69
- include Ruby2html::RailsHelper
70
- end
71
- ```
72
-
73
- File: `app/views/your_view.html.erb`
74
-
75
- Replace your ERB with beautiful Ruby code:
76
-
77
- ```erb
78
- <%=
79
- html(self) do
80
- h1 "Welcome to Ruby2html! 🎉", class: 'main-title', 'data-controller': 'welcome'
81
- div id: 'content', class: 'container' do
82
- link_to 'Home Sweet Home 🏠', root_path, class: 'btn btn-primary', 'data-turbo': false
83
- end
84
-
85
- @items.each do |item|
86
- h2 class: 'item-title', id: "item-#{item[:id]}" do
87
- item.title
88
- end
89
- p class: 'item-description' do
90
- item.description
91
- end
92
- end
93
-
94
- plain "<div>Inline html</div>".html_safe
95
-
96
- render partial: 'shared/navbar'
97
- end
98
- %>
99
- ```
100
-
101
- ### Benchmark
102
-
103
- ```bash
104
- ruby 3.3.3 (2024-06-12 revision f1c7b6f435) +YJIT [x86_64-linux]
105
- Warming up --------------------------------------
106
- GET /benchmark/html (ERB)
107
- 2.000 i/100ms
108
- GET /benchmark/ruby (Ruby2html)
109
- 1.000 i/100ms
110
- Calculating -------------------------------------
111
- GET /benchmark/html (ERB)
112
- 20.989 (±19.1%) i/s - 102.000 in 5.077353s
113
- GET /benchmark/ruby (Ruby2html)
114
- 20.438 (±19.6%) i/s - 97.000 in 5.010249s
115
-
116
- Comparison:
117
- GET /benchmark/html (ERB): 21.0 i/s
118
- GET /benchmark/ruby (Ruby2html): 20.4 i/s - same-ish: difference falls within error
119
- ```
120
-
121
- ### With ViewComponents
122
-
123
- Ruby2html seamlessly integrates with ViewComponents, offering flexibility in how you define your component's HTML structure. You can use the `call` method with Ruby2html syntax, or stick with traditional `.erb` template files.
124
-
125
- File: `app/components/application_component.rb`
126
-
127
- ```ruby
128
- # frozen_string_literal: true
129
-
130
- class ApplicationComponent < ViewComponent::Base
131
- include Ruby2html::ComponentHelper
132
- end
133
- ```
134
-
135
- #### Option 1: Using `call` method with Ruby2html
136
-
137
- File: `app/components/greeting_component.rb`
138
-
139
- ```ruby
140
- # frozen_string_literal: true
141
-
142
- class GreetingComponent < ApplicationComponent
143
- def initialize(name)
144
- @name = name
145
- end
146
-
147
- def call
148
- html do
149
- h1 class: 'greeting', 'data-user': @name do
150
- "Hello, #{@name}! 👋"
151
- end
152
- p class: 'welcome-message' do
153
- 'Welcome to the wonderful world of Ruby2html!'
154
- end
155
- end
156
- end
157
- end
158
- ```
159
-
160
- #### Option 2: Using traditional ERB template
161
-
162
- File: `app/components/farewell_component.rb`
163
-
164
- ```ruby
165
- # frozen_string_literal: true
166
-
167
- class FarewellComponent < ApplicationComponent
168
- def initialize(name)
169
- @name = name
170
- end
171
- end
172
- ```
173
-
174
- File: `app/components/farewell_component.html.rb`
175
-
176
- ```rb
177
- div class: 'farewell' do
178
- h1 class: 'farewell-message' do
179
- "Goodbye, #{@name}! 👋"
180
- end
181
- p class: 'farewell-text' do
182
- 'We hope to see you again soon!'
183
- end
184
- end
185
- ```
186
-
187
- This flexibility allows you to:
188
- - Use Ruby2html syntax for new components or when refactoring existing ones
189
- - Keep using familiar ERB templates where preferred
190
- - Mix and match approaches within your application as needed
191
-
192
- ### More Component Examples
193
-
194
- File: `app/components/first_component.rb`
195
-
196
- ```ruby
197
- # frozen_string_literal: true
198
-
199
- class FirstComponent < ApplicationComponent
200
- def initialize
201
- @item = 'Hello, World!'
202
- end
203
-
204
- def call
205
- html do
206
- h1 id: 'first-component-title' do
207
- 'first component'
208
- end
209
- div class: 'content-wrapper' do
210
- h2 'A subheading'
211
- end
212
- p class: 'greeting-text', 'data-testid': 'greeting' do
213
- @item
214
- end
215
- end
216
- end
217
- end
218
- ```
219
-
220
- File: `app/components/second_component.rb`
221
-
222
- ```ruby
223
- # frozen_string_literal: true
224
-
225
- class SecondComponent < ApplicationComponent
226
- def call
227
- html do
228
- h1 class: 'my-class', id: 'second-component-title', 'data-controller': 'second' do
229
- 'second component'
230
- end
231
- link_to 'Home', root_path, class: 'nav-link', 'data-turbo-frame': false
232
- end
233
- end
234
- end
235
- ```
236
-
237
- ## Without Rails
238
- ```ruby
239
- renderer = Ruby2html::Render.new(nil) do # nil is the context, you can use self or any other object
240
- html do
241
- head do
242
- title 'Ruby2html Example'
243
- end
244
- body do
245
- h1 'Hello, World!'
246
- end
247
- end
248
- end
249
-
250
- puts renderer.render # => "<html><head><title>Ruby2html Example</title></head><body><h1>Hello, World!</h1></body></html>"
251
- ```
252
-
253
- ## 🐢 Gradual Adoption
254
-
255
- One of the best features of Ruby2html is that you don't need to rewrite all your views at once! You can adopt it gradually, mixing Ruby2html with your existing ERB templates. This allows for a smooth transition at your own pace.
256
-
257
- ### Mixed usage example
258
-
259
- File: `app/views/your_mixed_view.html.erb`
260
-
261
- ```erb
262
- <h1>Welcome to our gradually evolving page!</h1>
263
-
264
- <%= render partial: 'legacy_erb_partial' %>
265
-
266
- <%=
267
- html(self) do
268
- div class: 'ruby2html-section' do
269
- h2 "This section is powered by Ruby2html!"
270
- p "Isn't it beautiful? 😍"
271
- end
272
- end
273
- %>
274
-
275
- <%= render ModernComponent.new %>
276
-
277
- <footer>
278
- <!-- More legacy ERB code -->
279
- </footer>
280
- ```
281
-
282
- In this example, you can see how Ruby2html seamlessly integrates with existing ERB code. This approach allows you to:
283
-
284
- - Keep your existing ERB templates and partials
285
- - Gradually introduce Ruby2html in specific sections
286
- - Use Ruby2html in new components while maintaining older ones
287
- - Refactor your views at your own pace
288
-
289
- Remember, there's no rush! You can keep your `.erb` files and Ruby2html code side by side until you're ready to fully transition. This flexibility ensures that adopting Ruby2html won't disrupt your existing workflow or require a massive rewrite of your application. 🌈
290
-
291
- ## 🛠 Development
292
-
293
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
294
-
295
- ## 🤝 Contributing
296
-
297
- Bug reports and pull requests are welcome on GitHub at https://github.com/sebyx07/ruby2html. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sebyx07/ruby2html/blob/master/CODE_OF_CONDUCT.md).
298
-
299
- ## 📜 License
300
-
301
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
302
-
303
- ## 🌈 Code of Conduct
304
-
305
- Everyone interacting in the Ruby2html project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sebyx07/ruby2html/blob/master/CODE_OF_CONDUCT.md).
306
-
307
- ## 🌟 Features
308
-
309
- - Write views in pure Ruby 💎
310
- - Seamless Rails integration 🛤️
311
- - ViewComponent support with flexible template options 🧩
312
- - Automatic HTML beautification 💅
313
- - Easy addition of custom attributes and data attributes 🏷️
314
- - Gradual adoption - mix with existing ERB templates 🐢
315
- - Improved readability and maintainability 📚
316
- - Full access to Ruby's power in your views 💪
317
-
318
- Start writing your views in Ruby today and experience the magic of Ruby2html! ✨🔮
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Add your own tasks in files placed in lib/tasks ending in .rake,
4
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
-
6
- require_relative 'config/application'
7
-
8
- Rails.application.load_tasks
@@ -1,2 +0,0 @@
1
- //= link_tree ../images
2
- //= link_directory ../stylesheets .css
File without changes
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
6
- * vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ApplicationCable
4
- class Channel < ActionCable::Channel::Base
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ApplicationCable
4
- class Connection < ActionCable::Connection::Base
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ApplicationComponent < ViewComponent::Base
4
- include Ruby2html::ComponentHelper
5
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- h1 'first component'
4
-
5
- div do
6
- h2 'A subheading'
7
- end
8
-
9
- another_div
10
-
11
- p @item