ruby2html 1.5.3 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gem/ruby2html/rails_components/form_with.rb +1 -1
- data/lib/gem/ruby2html/railtie.rb +14 -10
- data/lib/gem/ruby2html/render.rb +5 -13
- data/lib/gem/ruby2html/version.rb +1 -1
- data/ruby2html.gemspec +33 -0
- metadata +3 -77
- data/.dockerignore +0 -48
- data/.rspec +0 -2
- data/.rubocop.yml +0 -16
- data/.ruby-version +0 -1
- data/Dockerfile +0 -71
- data/README.md +0 -318
- data/Rakefile +0 -8
- data/app/assets/config/manifest.js +0 -2
- data/app/assets/images/.keep +0 -0
- data/app/assets/stylesheets/application.css +0 -15
- data/app/channels/application_cable/channel.rb +0 -6
- data/app/channels/application_cable/connection.rb +0 -6
- data/app/components/application_component.rb +0 -5
- data/app/components/first_component.html.rb +0 -11
- data/app/components/first_component.rb +0 -19
- data/app/components/second_component.rb +0 -12
- data/app/components/third_component/third_component.html.rb +0 -6
- data/app/components/third_component.rb +0 -7
- data/app/controllers/application_controller.rb +0 -7
- data/app/controllers/benchmark_controller.rb +0 -48
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/home_controller.rb +0 -16
- data/app/helpers/application_helper.rb +0 -4
- data/app/jobs/application_job.rb +0 -9
- data/app/mailers/application_mailer.rb +0 -6
- data/app/models/application_record.rb +0 -5
- data/app/models/concerns/.keep +0 -0
- data/app/views/benchmark/normal_html.html.erb +0 -31
- data/app/views/benchmark/ruby_2html.html.rb +0 -33
- data/app/views/home/form.html.rb +0 -14
- data/app/views/home/index.html.erb +0 -43
- data/app/views/home/rb_files.html.rb +0 -18
- data/app/views/layouts/application.html.erb +0 -21
- data/app/views/layouts/mailer.html.erb +0 -13
- data/app/views/layouts/mailer.text.erb +0 -1
- data/app/views/pwa/manifest.json.erb +0 -22
- data/app/views/pwa/service-worker.js +0 -26
- data/app/views/shared/_footer.html.rb +0 -3
- data/app/views/shared/_navbar.html.erb +0 -1
- data/config/application.rb +0 -45
- data/config/boot.rb +0 -6
- data/config/cable.yml +0 -10
- data/config/credentials.yml.enc +0 -1
- data/config/database.yml +0 -32
- data/config/environment.rb +0 -7
- data/config/environments/development.rb +0 -85
- data/config/environments/production.rb +0 -104
- data/config/environments/test.rb +0 -69
- data/config/initializers/assets.rb +0 -14
- data/config/initializers/content_security_policy.rb +0 -27
- data/config/initializers/filter_parameter_logging.rb +0 -10
- data/config/initializers/inflections.rb +0 -18
- data/config/initializers/permissions_policy.rb +0 -15
- data/config/locales/en.yml +0 -31
- data/config/puma.rb +0 -56
- data/config/routes.rb +0 -23
- data/config/storage.yml +0 -34
- data/config.ru +0 -8
- data/db/seeds.rb +0 -11
- data/lefthook.yml +0 -8
- data/lib/assets/.keep +0 -0
- data/lib/tasks/.keep +0 -0
- data/log/.keep +0 -0
- data/public/404.html +0 -67
- data/public/406-unsupported-browser.html +0 -66
- data/public/422.html +0 -67
- data/public/500.html +0 -66
- data/public/icon.png +0 -0
- data/public/icon.svg +0 -3
- data/public/robots.txt +0 -1
- data/storage/.keep +0 -0
- data/tmp/.keep +0 -0
- data/tmp/pids/.keep +0 -0
- data/tmp/storage/.keep +0 -0
- data/vendor/.keep +0 -0
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
|
data/app/assets/images/.keep
DELETED
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,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class FirstComponent < ApplicationComponent
|
4
|
-
def initialize
|
5
|
-
@item = 'Hello, World!'
|
6
|
-
end
|
7
|
-
|
8
|
-
def another_div
|
9
|
-
div do
|
10
|
-
"Item value: #{@item}"
|
11
|
-
end
|
12
|
-
|
13
|
-
div class: 'another' do
|
14
|
-
h2 'Another subheading from component'
|
15
|
-
end
|
16
|
-
|
17
|
-
h1 'Yet Another heading from component'
|
18
|
-
end
|
19
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class ApplicationController < ActionController::Base
|
4
|
-
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
|
5
|
-
allow_browser versions: :modern
|
6
|
-
include Ruby2html::RailsHelper
|
7
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class BenchmarkController < ApplicationController
|
4
|
-
def normal_html
|
5
|
-
@complex_data = generate_complex_data
|
6
|
-
end
|
7
|
-
|
8
|
-
def ruby_2html
|
9
|
-
@complex_data = generate_complex_data
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
def generate_complex_data
|
14
|
-
{
|
15
|
-
users: 50.times.map do |i|
|
16
|
-
{
|
17
|
-
id: i + 1,
|
18
|
-
name: Faker::Name.name,
|
19
|
-
email: Faker::Internet.email,
|
20
|
-
address: {
|
21
|
-
street: Faker::Address.street_address,
|
22
|
-
city: Faker::Address.city,
|
23
|
-
country: Faker::Address.country
|
24
|
-
},
|
25
|
-
orders: rand(1..5).times.map do
|
26
|
-
{
|
27
|
-
id: Faker::Alphanumeric.alphanumeric(number: 10),
|
28
|
-
total: Faker::Commerce.price(range: 10..1000.0),
|
29
|
-
items: rand(1..10).times.map do
|
30
|
-
{
|
31
|
-
name: Faker::Commerce.product_name,
|
32
|
-
price: Faker::Commerce.price(range: 5..500.0),
|
33
|
-
quantity: rand(1..5)
|
34
|
-
}
|
35
|
-
end
|
36
|
-
}
|
37
|
-
end
|
38
|
-
}
|
39
|
-
end,
|
40
|
-
stats: {
|
41
|
-
total_users: 50,
|
42
|
-
average_orders_per_user: rand(1.0..5.0).round(2),
|
43
|
-
most_expensive_item: Faker::Commerce.product_name,
|
44
|
-
most_popular_country: Faker::Address.country
|
45
|
-
}
|
46
|
-
}
|
47
|
-
end
|
48
|
-
end
|
File without changes
|
data/app/jobs/application_job.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class ApplicationJob < ActiveJob::Base
|
4
|
-
# Automatically retry jobs that encountered a deadlock
|
5
|
-
# retry_on ActiveRecord::Deadlocked
|
6
|
-
|
7
|
-
# Most jobs are safe to ignore if the underlying records are no longer available
|
8
|
-
# discard_on ActiveJob::DeserializationError
|
9
|
-
end
|
data/app/models/concerns/.keep
DELETED
File without changes
|
@@ -1,31 +0,0 @@
|
|
1
|
-
<h1>Benchmark: Normal HTML (ERB)</h1>
|
2
|
-
|
3
|
-
<h2>User Statistics</h2>
|
4
|
-
<ul>
|
5
|
-
<li>Total Users: <%= @complex_data[:stats][:total_users] %></li>
|
6
|
-
<li>Average Orders per User: <%= @complex_data[:stats][:average_orders_per_user] %></li>
|
7
|
-
<li>Most Expensive Item: <%= @complex_data[:stats][:most_expensive_item] %></li>
|
8
|
-
<li>Most Popular Country: <%= @complex_data[:stats][:most_popular_country] %></li>
|
9
|
-
</ul>
|
10
|
-
|
11
|
-
<h2>User List</h2>
|
12
|
-
<% @complex_data[:users].each do |user| %>
|
13
|
-
<div class="user-card">
|
14
|
-
<h3><%= user[:name] %></h3>
|
15
|
-
<p>Email: <%= user[:email] %></p>
|
16
|
-
<p>Address: <%= "#{user[:address][:street]}, #{user[:address][:city]}, #{user[:address][:country]}" %></p>
|
17
|
-
|
18
|
-
<h4>Orders</h4>
|
19
|
-
<% user[:orders].each do |order| %>
|
20
|
-
<div class="order">
|
21
|
-
<p>Order ID: <%= order[:id] %></p>
|
22
|
-
<p>Total: $<%= order[:total] %></p>
|
23
|
-
<ul>
|
24
|
-
<% order[:items].each do |item| %>
|
25
|
-
<li><%= item[:name] %> - $<%= item[:price] %> (Quantity: <%= item[:quantity] %>)</li>
|
26
|
-
<% end %>
|
27
|
-
</ul>
|
28
|
-
</div>
|
29
|
-
<% end %>
|
30
|
-
</div>
|
31
|
-
<% end %>
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
h1 'Benchmark: Ruby2html'
|
4
|
-
|
5
|
-
h2 'User Statistics'
|
6
|
-
ul do
|
7
|
-
li { plain "Total Users: #{@complex_data[:stats][:total_users]}" }
|
8
|
-
li { plain "Average Orders per User: #{@complex_data[:stats][:average_orders_per_user]}" }
|
9
|
-
li { plain "Most Expensive Item: #{@complex_data[:stats][:most_expensive_item]}" }
|
10
|
-
li { plain "Most Popular Country: #{@complex_data[:stats][:most_popular_country]}" }
|
11
|
-
end
|
12
|
-
|
13
|
-
h2 'User List'
|
14
|
-
@complex_data[:users].each do |user|
|
15
|
-
div class: 'user-card' do
|
16
|
-
h3 user[:name]
|
17
|
-
p { plain "Email: #{user[:email]}" }
|
18
|
-
p { plain "Address: #{user[:address][:street]}, #{user[:address][:city]}, #{user[:address][:country]}" }
|
19
|
-
|
20
|
-
h4 'Orders'
|
21
|
-
user[:orders].each do |order|
|
22
|
-
div class: 'order' do
|
23
|
-
p { plain "Order ID: #{order[:id]}" }
|
24
|
-
p { plain "Total: $#{order[:total]}" }
|
25
|
-
ul do
|
26
|
-
order[:items].each do |item|
|
27
|
-
li { plain "#{item[:name]} - $#{item[:price]} (Quantity: #{item[:quantity]})" }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/app/views/home/form.html.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
<h1>Home</h1>
|
2
|
-
|
3
|
-
<%= render FirstComponent.new %>
|
4
|
-
<%= render SecondComponent.new %>
|
5
|
-
<%= render ThirdComponent.new %>
|
6
|
-
|
7
|
-
<%=
|
8
|
-
html(self) do
|
9
|
-
h1(id: 4) { "Inside" }
|
10
|
-
h2 "Inside 2", id: '44'
|
11
|
-
h1 "ok"
|
12
|
-
h1 "ok"
|
13
|
-
h1 "ok"
|
14
|
-
h1 "ok"
|
15
|
-
h1 "ok"
|
16
|
-
div do
|
17
|
-
link_to 'home 1', root_path
|
18
|
-
end
|
19
|
-
link_to 'home 2', root_path
|
20
|
-
|
21
|
-
div do
|
22
|
-
link_to 'home 3', root_path
|
23
|
-
end
|
24
|
-
|
25
|
-
render partial: 'shared/navbar'
|
26
|
-
|
27
|
-
@items.each do |item|
|
28
|
-
h1 item[:title]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
%>
|
32
|
-
|
33
|
-
<%= render partial: 'shared/navbar' %>
|
34
|
-
|
35
|
-
<%=
|
36
|
-
html(self) do
|
37
|
-
@items.each do |item|
|
38
|
-
h1 item[:title]
|
39
|
-
end
|
40
|
-
|
41
|
-
turbo_frame id: '4'
|
42
|
-
end
|
43
|
-
%>
|